1.0.5 • Published 8 years ago

stringify-stream v1.0.5

Weekly downloads
272
License
MIT
Repository
github
Last release
8 years ago

stringify-stream

Streaming Transform of objects via JSON.stringify

npm version build status dependencies devDependencies

Usage

Stream objects into newline separated JSON strings.

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();
    }));
});

Stream objects into an Array encoded as a JSON string.

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();
    }));
});

Install

npm install stringify-stream

License

MIT License

1.0.5

8 years ago

1.0.4-beta

8 years ago

1.0.3

9 years ago

1.0.2

9 years ago

1.0.1

9 years ago

1.0.0

10 years ago

0.1.3

11 years ago

0.1.2

11 years ago

0.1.1

11 years ago

0.1.0

11 years ago