Skip to main content

take()

take<T>(size): OperatorFunction<T, T>

Defined in: src/Take.ts:19

Creates an operator that passes through only the first size items and then stops iterating the source.

A size of 0 or less gives an empty iteration and the source is not read.

Type Parameters​

T​

T

Parameters​

size​

number

the number of items to take

Returns​

OperatorFunction<T, T>

an operator function

Example​

const result = await chain([1, 2, 3, 4, 5]).take(2).toArray();
// => [1, 2]