Socket
Socket
Sign inDemoInstall

ndjson

Package Overview
Dependencies
Maintainers
2
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ndjson - npm Package Compare versions

Comparing version 1.2.1 to 1.2.2

2

index.js

@@ -6,3 +6,3 @@ var through = require('through2')

module.exports = parse
module.exports.serialize = serialize
module.exports.serialize = exports.stringify = serialize
module.exports.parse = parse

@@ -9,0 +9,0 @@

{
"name": "ndjson",
"version": "1.2.1",
"version": "1.2.2",
"description": "streaming line delimited json parser + serializer",

@@ -5,0 +5,0 @@ "main": "index.js",

# ndjson
#### streaming line delimited json parser + serializer
#### streaming newline delimited json parser + serializer

@@ -10,6 +10,6 @@ [![NPM](https://nodei.co/npm/ndjson.png)](https://nodei.co/npm/ndjson/)

```
var ldj = require('ndjson')
var ndjson = require('ndjson')
```
#### ldj.parse()
#### ndjson.parse()

@@ -27,3 +27,3 @@ returns a transform stream that accepts newline delimited json and emits objects

If you want to discard non-valid JSON messages, you can call `ldj.parse({strict: false})`
If you want to discard non-valid JSON messages, you can call `ndjson.parse({strict: false})`

@@ -34,3 +34,3 @@ usage:

fs.createReadStream('data.txt')
.pipe(ldj.parse())
.pipe(ndjson.parse())
.on('data', function(obj) {

@@ -41,3 +41,3 @@ // obj is a javascript object

#### ldj.serialize()
#### ndjson.serialize() / ndjson.stringify()

@@ -49,3 +49,3 @@ returns a transform stream that accepts json objects and emits newline delimited json

```js
var serialize = ldj.serialize()
var serialize = ndjson.serialize()
serialize.on('data', function(line) {

@@ -52,0 +52,0 @@ // line is a line of stringified JSON with a newline delimiter at the end

@@ -28,2 +28,25 @@ var test = require('tape')

test('.parse - strict:true error', function (t) {
var parser = ndj.parse({strict: true})
try {
parser.write('{"no":"json"\n')
} catch(e) {
t.pass('error thrown')
t.end()
}
})
test('.parse - strict:false error', function (t) {
var parser = ndj.parse({strict: false})
parser.once('data', function (data) {
t.ok(data.json, 'parse second one')
t.end()
})
try {
parser.write('{"json":false\n{"json":true}\n')
} catch(e) {
t.fail('should not call an error')
}
})
test('.serialize', function(t) {

@@ -30,0 +53,0 @@ var serializer = ndj.serialize()

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