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

json-text-sequence

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

json-text-sequence - npm Package Compare versions

Comparing version 0.2.0 to 0.3.0

33

lib/index.js

@@ -5,5 +5,6 @@ 'use strict'

const stream = require('stream')
const DelimitStream = require('delimit-stream')
const { DelimitedStream } = require('@sovpro/delimited-stream')
const RS = (this.RS = '\x1e')
const RS = '\x1e'
exports.RS = RS

@@ -34,3 +35,3 @@ // Parse a JSON text sequence stream as defined in

// var p = new parser()
// .on('json', function(obj) {
// .on('data', function(obj) {
// console.log('Valid', obj);

@@ -47,10 +48,10 @@ // })

// @nodoc
constructor() {
super()
this._readableState.objectMode = true
this._stream = new DelimitStream(RS)
// I can't figure out how to make 'error' happen. Maybe it can't?
.on('error', /* istanbul ignore next */ e => this.emit('error', e))
constructor(opts = {}) {
super({
...opts,
readableObjectMode: true
})
this._stream = new DelimitedStream(RS)
.on('data', d => {
// NOTE: delimit-stream will deal with repeated delimiters.
// NOTE: delimited-stream will deal with repeated delimiters.
// d.length will always be > 0

@@ -61,7 +62,7 @@ assert.ok(d.length > 0)

if (d[d.length - 1] !== 0x0a) {
return this.emit('truncated', d)
this.emit('truncated', d)
} else {
try {
const j = JSON.parse(d)
return this.push(j)
this.push(j)
} catch (ignored) {

@@ -76,11 +77,12 @@ this.emit('invalid', d)

_transform(chunk, encoding, cb) {
return this._stream._transform(chunk, encoding, cb)
this._stream.write(chunk, encoding, cb)
}
// @nodoc
_flush(cb) {
return this._stream._flush(cb)
_final(cb) {
this._stream.end(null, null, cb)
}
}
exports.parser = JSONSequenceParser
exports.Parser = JSONSequenceParser

@@ -120,1 +122,2 @@ // Generate a JSON text sequence stream as defined in

exports.generator = JSONSequenceGenerator
exports.Generator = JSONSequenceGenerator
{
"name": "json-text-sequence",
"version": "0.2.0",
"version": "0.3.0",
"description": "Parse and generate RS-delimited JSON sequences according to draft-ietf-json-text-sequence",

@@ -13,3 +13,4 @@ "main": "./lib/index.js",

"test": "ava test/*.js",
"release": "npm version patch && git push --follow-tags && npm publish"
"release": "npm version patch && git push --follow-tags && npm publish",
"lint": "eslint lib/*.js test/*.js examples/*.js"
},

@@ -33,6 +34,10 @@ "repository": {

"dependencies": {
"delimit-stream": "0.1.0"
"@sovpro/delimited-stream": "^1.1.0"
},
"devDependencies": {
"@cto.af/eslint-config": "^0.0.3",
"ava": "^3.15.0",
"eslint": "^7.20.0",
"eslint-plugin-ava": "^11.0.0",
"eslint-plugin-node": "^11.1.0",
"nyc": "^15.1.0"

@@ -39,0 +44,0 @@ },

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