API · Select
slice()
Emit values from a zero-based start index up to, but not including, an end index.
Signature
slice(start: number, end?: number): Exstream<T, C> Example
exstream(['a', 'b', 'c', 'd']).slice(1, 3).valuesSync()
// ['b', 'c'] Parameters
startInclusive zero-based lower bound. Values below zero effectively start at the first input.
endExclusive upper bound. Fractions are accepted and compared directly against integer input indexes.
Behavior
Both bounds are parsed with parseFloat; the TypeScript API intentionally accepts numbers. start must be lower than end, and neither may parse to NaN. slice(0, Infinity) returns the same stream instance without adding an operator.
The operator preserves order and context and adds no queue. Reaching a finite end destroys this branch and releases upstream demand. It may read the value at index end to discover that the range has finished, but that value is not emitted. Existing record errors pass through and do not advance the successful-value index.
Forms
stream.slice(10, 20)
exstream.pipeline().slice(10, 20)
exstream.slice(10, 20, stream)
stream.through(exstream.slice(10, 20))