Skip to content

Function: collect()

@kortexya/reasoninglayer


@kortexya/reasoninglayer / collect

collect<TItem>(items): Promise<TItem[]>

Defined in: src/pagination.ts:232

Collect an async iterator into an array.

TItem

AsyncIterable<TItem>

The iterator.

Promise<TItem[]>

Every item it yields.

Convenience for the small case. It holds the whole result in memory, which is the thing iteration exists to avoid — bound it with the iterator’s own limit rather than with a slice afterwards.

const firstTen = await collect(client.terms.iterateTerms(undefined, { limit: 10 }));