Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newline delimited JSON streaming made easy
JavaScript
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
test
.gitignore
History.md
Makefile
README.md
njstream.js
package.json

README.md

NJStream

Newline delimited JSON streaming made easy

Installation

  $ npm install njstream

Examples

Simple usage

var NJStream = require('njstream');
var njstream = new NJStream();

njstream.on('parsed', function(json_data){
  console.log(json_data);
});

for(var i = 0; i < 100000; i++){
  stream.write(JSON.stringify({"foo": "bar"}) + '\r\n');
}

Using superagent

var request = require('superagent')
  , NJStream = require('njstream');

var njstream = new NJStream();

njstream.on('parsed', function(json_data){
  console.log(json_data);
});

request
.get('http://your.server/')
.pipe(njstream);

Passing it to an http request

var http = require('http')
  , NJStream = require('njstream');

var njstream = new NJStream();

njstream.on('parsed', function(json_data){
  console.log(json_data);
});

var request = http.get('your.domain.io/json_delimited_data/');

request.on('response', function(res){
  res.pipe(njstream);
});
Something went wrong with that request. Please try again.