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 | 19x 14x 14x 14x 213x 2x 2x 2x 103x 2x | import { AsyncArrayMaker } from "../types"; export const asyncArray: AsyncArrayMaker = (typer, header) => ({ async encode(ctx, data) { const { length } = data; header.encode(ctx, length); for (let i = 0; i < length; i++) { await typer.encode(ctx, data[i]); } }, async decode(ctx) { const length = header.decode(ctx); const data = []; for (let i = 0; i < length; i++) { data.push(await typer.decode(ctx)); } return data; } }); |