Ignore - uhop/stream-json GitHub Wiki
Ignore removes matching subobjects from a token stream entirely. It is built on FilterBase and rejects matched values without emitting any replacement tokens.
Introduction
const {ignore} = require('stream-json/filters/ignore.js');
const {parser} = require('stream-json/parser.js');
const {streamArray} = require('stream-json/streamers/stream-array.js');
const pipeline = chain([
fs.createReadStream('sample.json'),
parser(), // packs keys by default, otherwise {packKeys: true}
ignore({filter: /\bmeta\b/i}),
streamArray()
]);
pipeline.on('data', data => console.log(data));
The upstream must produce packed keys (keyValue tokens) for this filter to work.
API
ignore is built on FilterBase. See Replace for the closely related filter that substitutes values instead of removing them.
Options:
filter- If it returns a truthy value, the current object is removed completely with all its possible subobjects.
- It is called only for the following tokens:
startObject,startArray,startString,startNumber,stringValue,numberValue,nullValue,trueValue,falseValue.
pathSeparatoronce
Static methods and properties
Same as Replace:
ignore(options)— factory function returning a filter for use inchain().ignore.asStream(options)— returns aDuplexstream (object-mode both sides) for.pipe()usage.ignore.withParser(options)— creates aparser() + ignore()pipeline.ignore.withParserAsStream(options)— same, wrapped as a Duplex stream.