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 26 | 19x 19x 1x 1x 1x 1x 2x 2x 1x 1x 1x 2x 1x | import { asyncDefine } from "../asyncDefine"; import { AsyncRecordFactory, GetType } from "../types"; export const asyncRecord: AsyncRecordFactory = (sd, headSd, keySd) => asyncDefine( async (ctx, data) => { const { length } = Object.keys(data); headSd.ser(ctx, length); for (const key in data) { keySd.ser(ctx, key); await sd.ser(ctx, data[key]); } }, async (ctx) => { const length = headSd.des(ctx); const data: Record< GetType<typeof keySd>, GetType<typeof sd> > = {}; for (let i = 0; i < length; i++) { data[keySd.des(ctx)] = await sd.des(ctx); } return data; } ); |