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 | 19x 1x 1x 1x 2x 2x 1x 1x 1x 2x 1x | import { RecordMaker, TypeOf } from "../types"; export const record: RecordMaker = (typer, header, keyer) => ({ encode(ctx, data) { const { length } = Object.keys(data); header.encode(ctx, length); for (const key in data) { keyer.encode(ctx, key); typer.encode(ctx, data[key]); } }, decode(ctx) { const length = header.decode(ctx); const data: Record<string, TypeOf<typeof typer>> = {}; for (let i = 0; i < length; i++) { data[keyer.decode(ctx)] = typer.decode(ctx); } return data; } }); |