(
method: string,
call: (pageArg: { offset: bigint; limit: bigint }) => Promise<unknown>,
extract: (page: unknown) => { items: Item[]; next: Array<bigint> | [] },
)
| 27 | next_offset.length > 0 ? next_offset[0] : null; |
| 28 | |
| 29 | const paginated = async <Item>( |
| 30 | method: string, |
| 31 | call: (pageArg: { offset: bigint; limit: bigint }) => Promise<unknown>, |
| 32 | extract: (page: unknown) => { items: Item[]; next: Array<bigint> | [] }, |
| 33 | ): Promise<Item[]> => { |
| 34 | const items: Item[] = []; |
| 35 | let offset: bigint | null = 0n; |
| 36 | while (offset !== null) { |
| 37 | const response = await call({ offset, limit: PAGE_SIZE }); |
| 38 | const ok = unwrapOk<unknown>(response, method); |
| 39 | const page = extract(ok); |
| 40 | items.push(...page.items); |
| 41 | offset = nextOffset(page.next); |
| 42 | } |
| 43 | return items; |
| 44 | }; |
| 45 | |
| 46 | /** |
| 47 | * Builds an authenticated agent-js actor for the target station. |
no test coverage detected