-
-
Notifications
You must be signed in to change notification settings - Fork 51
Assembler
Eugene Lazutkin edited this page Jun 18, 2018
·
6 revisions
Assembler receives a token stream and assembles JavaScript objects. It is used as a building block for streamers.
const Asm = require('stream-json/Assembler');
const {parser} = require('stream-json');
const {chain} = require('stream-chain');
const fs = require('fs');
const zlib = require('zlib');
const pipeline = chain([
fs.createReadStream('data.json.gz'),
zlib.createGunzip(),
parser()
]);
const asm = Asm.connectTo(pipeline);
asm.on('done', asm => console.log(asm.current));Assembler is based on EventEmitter. Its constructor takes no arguments.