Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | 19x 19x 201x 3x 305x 1808x 202x 202x 1204x 202x 19x 1x | import { asyncDefine } from "../asyncDefine"; import { AsyncStructFactory, AsyncTupleFactory } from "../types"; export const asyncStruct: AsyncStructFactory = (definition) => { const obj = definition instanceof Array ? () => [] : () => ({}); return asyncDefine( async (ctx, data) => { for (const key in definition) { await definition[key].ser(ctx, data[key]); } }, async (ctx) => { // eslint-disable-next-line @typescript-eslint/no-explicit-any const data = obj() as any; for (const key in definition) { data[key] = await definition[key].des(ctx); } return data; } ); }; export const asyncTuple: AsyncTupleFactory = (...defintion) => asyncStruct(defintion); |