Class: DocumentTagger

@e2fyi/streams.DocumentTagger(opts)

Transform Object stream (objectMode=true) to tag with an autoIncrement id. An object or function can be optionally provided to mutate each object in the stream.

Constructor

new DocumentTagger(opts)

Create a new DocumentTagger stream.

Parameters:
Name Type Description
opts DocumentTaggerSettings

Settings for the stream.

Source:
Fires:
Example
const docTagger = new DocumentTagger({autoIncrement: 'id', mutate: { project: 'test' }});
someReadableStreamFromArray([{text: 'abc'}, {text: 'efg'}])
  .pipe(docTagger)
  .pipe(process.stdout);
// stdout >
// {"text": "abc", "id": 0, "project": "test"}
// {"text": "efg", "id": 1, "project": "test"}

Extends

  • stream.Transform