stringify-stream2

1.0.0 • Public • Published

stringify-stream2

TEMP package until https://github.com/mimetnet/node-stringify-stream/pull/1 is merged

Streaming Transform of objects via JSON.stringify

build status npm version dependencies devDependencies

Usage

Stream objects into newline separated JSON strings.

var test = require('tap').test
    , 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();
    }));
});

Stream objects into an Array encoded as a JSON string.

var test = require('tap').test
    , 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();
    }));
});

Install

npm install stringify-stream

Package Sidebar

Install

npm i stringify-stream2

Weekly Downloads

1

Version

1.0.0

License

MIT

Last publish

Collaborators

  • jcrugzz