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

binary-parse-stream

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

binary-parse-stream - npm Package Compare versions

Comparing version 1.2.1 to 1.2.2

70

index.js

@@ -6,4 +6,6 @@ 'use strict';

, inherits = require('util').inherits
, Readable = require('readable')
, abs = Math.abs
var One = exports.One = -1
exports.One = -1

@@ -16,54 +18,36 @@ inherits(BinaryParseStream, TransformStream)

this._queue = null
this._needed = 0
this._single = false
this._parser = this._parse()
this.__read = Readable(Buffer(0))
this.__restart()
}
BinaryParseStream.prototype._transform = function(fresh, encoding, cb) {
var queue = this._queue === null
? fresh
: Buffer.concat(this._queue, fresh)
BinaryParseStream.prototype._transform = function(fresh, encoding, cb) { var self = this
this.__read.push(fresh)
var needed = this._needed
, single = this._single
while (this.__read.able >= abs(this.__needed)) {
var ret
, chunk = this.__read(this.__needed)
while (queue.length >= needed) {
var chunk = queue.slice(0, needed)
queue = queue.slice(needed)
try { ret = this.__parser.next(chunk) }
catch (e) {
this.emit('error', e)
this.__restart()
continue
}
var ret
, err
try {
if (single)
ret = this._parser.next(chunk[0])
else
ret = this._parser.next(chunk)
if (ret.done) {
this.push(ret.value)
this.__restart()
continue
}
catch (e) {
err = e
ret = { done: true }
}
if (!ret.done) {
var value = ret.value
single = value === One
needed = single
? 1
: value
}
else {
if (err)
this.emit('error', err)
else
this.push(ret.value)
needed = 0
this._parser = this._parse()
}
this.__needed = ret.value
}
this._queue = queue
this._needed = needed
this._single = single
return cb()
}
BinaryParseStream.prototype.__restart = function() {
this.__needed = 0
this.__parser = this._parse()
}
{
"name": "binary-parse-stream",
"version": "1.2.1",
"version": "1.2.2",
"description": "Painless streaming binary protocol parsers using generators.",

@@ -22,3 +22,6 @@ "main": "index.js",

},
"homepage": "https://github.com/nathan7/binary-parse-stream"
"homepage": "https://github.com/nathan7/binary-parse-stream",
"dependencies": {
"readable": "~1.1.2"
}
}

Sorry, the diff of this file is not supported yet

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