Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Streaming version of `JSON.stringify` for node.js
JavaScript
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
examples tests, readme
test fixes failing test, and the brain typo that made it fail.
.gitignore .gitignore node_modules
.travis.yml stop emailing!
LICENSE MIT License
package.json 0.1.3
readme.md Integrate Travis CI for automatic testing
streamify.js

readme.md

JSON Streamify

Build Status

A streaming version of JSON.stringify.

npm install json-streamify

Methods

streamify(object, function)

Passes the function chunks of the object until there is none of the object left. streamify is a synchronous function.

var assert = require('assert')
  , streamify = require('../streamify').streamify
  , streamingWrite = require('../streamify').streamingWrite
  , fs = require('fs')
  , object = { a: 1, b: 2, c: 3}

var str = '';
streamify(object, function(data) { str += data; });
console.log(str);
// => {"a":1,"b":2,"c":3}

streamingWrite(filepath, object, callback)

Writes chunks of the object to the given filepath until there is none of the object left. When it finishes, it calls callback.

var str = '';
streamingWrite('./ACOOLFILE.txt', object, function(data) { str += data; }, function() {

  console.log(fs.readFileSync('./ACOOLFILE'));
  // => {"a":1,"b":2,"c":3}
});

Most of this was written by James Halliday, with a few small things by David Trejo.

TODOs

  • allow a stream to be passed into streamify(object, stream)?
Something went wrong with that request. Please try again.