Skip to main content

interval()

interval<T>(size): OperatorFunction<T, [T, T]>

Defined in: src/Interval.ts:23

Creates an operator that splits the source into groups of size items and emits only the first and the last item of each group as a pair. The last group may be smaller; a group of one item yields that item twice.

If the source throws, the interval collected so far is emitted first and the error is thrown after it.

Type Parameters​

T​

T

Parameters​

size​

number

the number of items in a group

Returns​

OperatorFunction<T, [T, T]>

an operator function

Example​

const result = await chain(["a", "b", "c", "d", "e", "f", "g"])
.interval(3)
.toArray();
// => [["a", "c"], ["d", "f"], ["g", "g"]]