Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

newline-json

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

newline-json

New-line separated JSON streaming

  • 0.1.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
213
decreased by-6.99%
Maintainers
1
Weekly downloads
 
Created
Source

newline-json

Just like JSONStream, but instead of streaming valid JSON arrays, it streams new-line separated JSON objects.

It requires browserify 3.x from 0.1 upwards, versions 0.0.x are compatible with browserify 2.x.

Example

If you have a readable stream like

var n = 100;
var nlj = new Readable();
nlj._read = function _read () {
  if (n--)
    nlj.push('{"this":"is","js":"on"}\n'); // new-line separated JSON!
  else
    nlj.push(null);
}
return nlj;

you can pipe it to the parser

var Parser = require('newline-json').Parser;
var parser = new Parser();
nlj.pipe(parser);

what comes out of the parser will be the the objects you piped to it, parsed. You can pipe those again to the stringifier:

var Stringifier = require('newline-json').Stringifier;
var stringifier = new Stringifier();
parser.pipe(stringifier);

And if you have nothing better to do today, be sure to try

parser.pipe(stringifier);
stringifier.pipe(parser);

Why ?

Couldn't find one on npm that used the Transform, and IMO if you don't need to parse complex object paths, then you'd be better off using a new-line separated JSON. Also, it's probably much easier to write parsers like this in other languages and environments, which is good if your stack is not 100% node.js.

Keywords

FAQs

Package last updated on 29 May 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc