Skip to content
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().

Introduction

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.`));

API

The returned factory function takes one argument: options described in Parser, and returns a new instance of Parser.

Clone this wiki locally