-
-
Notifications
You must be signed in to change notification settings - Fork 47
Main module
Eugene Lazutkin edited this page Jun 18, 2018
·
6 revisions
The main module returns a factory function, which produces instances of Parser decorated with emit().
const makeParser = require('stream-json');
const fs = require('fs');
const pipeline = fs.createReadStream('sample.json').pipe(makeParser());
let objectCounter = 0;
pipeline.on('startObject', () => ++objectCounter);
pipeline.on('end', console.log(`Found ${objectCounter} objects.`));
The returned factory function takes one argument: options
described in Parser, and returns a new instance of Parser
.