Streaming Transform of objects via JSON.stringify
var test = require('tape')
, concat = require('concat-stream')
, streamify = require('stream-array')
, stringify = require('stringify-stream')
;
test('newlines', function(t) {
streamify([1,2,3]).pipe(stringify()).pipe(concat(function(err, res) {
t.equal('1\n2\n3', res.toString(), 'result matches expectation');
t.end();
}));
});
var test = require('tape')
, concat = require('concat-stream')
, streamify = require('stream-array')
, stringify = require('stringify-stream');
;
test('array', function(t) {
var opts = {open:'[', close:']'};
streamify([1,2,3]).pipe(stringify(opts)).pipe(concat(function(err, res) {
t.equal('[1,2,3]', res.toString(), 'result matches expectation');
t.end();
}));
});
npm install stringify-stream