Skip to content

Function: skip()

skip<T>(count): Operator<T, T>

Defined in: operators/skip.ts:14

Creates a stream operator that skips the first specified number of values from the source stream.

This operator is useful for "fast-forwarding" a stream. It consumes the initial count values from the source stream without emitting them to the output. Once the count is reached, it begins to pass all subsequent values through unchanged.

Type Parameters

T

T = any

The type of the values in the source and output streams.

Parameters

count

number

The number of values to skip from the beginning of the stream.

Returns

Operator<T, T>

An Operator instance that can be used in a stream's pipe method.

Examples

From skip.spec.ts:4

typescript
const testStream = from([1, 2, 3, 4, 5]);
const countToSkip = 3;
const skippedStream = testStream.pipe(skip(countToSkip));
let results: any[] = [];
skippedStream.subscribe({
  next: (value) => results.push(value),
  complete: () => {
    expect(results).toEqual([4, 5]); // Should skip the first 3 values and emit [4, 5]
    done();
  },
});

Released under the MIT License.