Function: collect()
@kortexya/reasoninglayer / collect
Function: collect()
Section titled “Function: collect()”collect<
TItem>(items):Promise<TItem[]>
Defined in: src/pagination.ts:232
Collect an async iterator into an array.
Type Parameters
Section titled “Type Parameters”TItem
Parameters
Section titled “Parameters”AsyncIterable<TItem>
The iterator.
Returns
Section titled “Returns”Promise<TItem[]>
Every item it yields.
Remarks
Section titled “Remarks”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.
Example
Section titled “Example”const firstTen = await collect(client.terms.iterateTerms(undefined, { limit: 10 }));