Skip to content

V2: utils: skip()

Eugene Lazutkin edited this page Aug 3, 2022 · 1 revision

(Since 2.2.0)

skip() skips a given number of items from a stream. It is returned by require('stream-chain/utils/skip') and it is based on Transform.

Factory function: skip(options)

It takes options and returns a Transform stream.

options can be one of these:

  • an object detailed in the Node's documentation.
    • readableObjectMode and writableObjectMode are always set to `true.
    • The following custom options are recognized:
      • (optional) n is a non-negative integer indicating how many items to skip. Default: 0.
  • Otherwise it is assumed to be a non-negative integer, same as n described above.

Static property: skip.Constructor

A constructor of the underlying stream class produced by skip(). Useful to inspect objects with instanceof.

Static property: skip.Constructor.make

An alias to skip. Useful with metaprogramming.

Examples

const {chain} = require('stream-chain');
const skip = require('stream-chain/utils/skip');

// skip 10 items
const pipeline = chain([
  skip(10)
  // ... the rest of the pipeline
]);
Clone this wiki locally