through-json

Through stream that parses each write as a JSON message.

5 个版本
安装
npm install through-json
yarn add through-json
pnpm add through-json
bun add through-json
README

through-json

Through stream that parses each write as a JSON message.

npm install through-json

build status

Usage

var parse = require('through-json');

// parse returns a streams2 through stream

var p = parse();

p.on('data', function(data) {
	console.log(data.message);
});

p.on('end', function() {
	console.log('no more messages');
});

// each write must be a complete JSON message

p.write('{"message":"test"}');
p.write('{"message":"another test"}');
p.end();

Running the above program produces the following output

test
another test
no more messages

License

MIT

版本列表
1.1.0 2014-07-12
1.0.1 2014-06-09
1.0.0 2014-06-09
0.1.1 2014-03-20
0.1.0 2014-03-20