Socket
Socket
Sign inDemoInstall

msgpack5

Package Overview
Dependencies
Maintainers
1
Versions
51
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

msgpack5 - npm Package Compare versions

Comparing version 1.1.0 to 1.1.1

25

lib/streams.js

@@ -33,5 +33,12 @@

Encoder.prototype._transform = function(obj, enc, done) {
var buf = this._msgpack.encode(obj).slice(0)
var buf = null
, header = null
try {
buf = this._msgpack.encode(obj).slice(0)
} catch(err) {
this.emit('error', err)
return done()
}
if (this._header) {

@@ -68,3 +75,7 @@ header = new Buffer(4)

function decodeWithoutHeader(buf, enc, done) {
this.push(this._msgpack.decode(buf))
try {
this.push(this._msgpack.decode(buf))
} catch(err) {
this.emit('error', err)
}
done()

@@ -89,5 +100,9 @@ }

if (this._chunks.length >= this._length) {
this.push(this._msgpack.decode(this._chunks.slice(0, this._length)))
this._chunks.consume(this._length)
this._length = -1
try {
this.push(this._msgpack.decode(this._chunks.slice(0, this._length)))
this._chunks.consume(this._length)
this._length = -1
} catch(err) {
this.emit('error', err)
}
}

@@ -94,0 +109,0 @@

2

package.json
{
"name": "msgpack5",
"version": "1.1.0",
"version": "1.1.1",
"description": "A msgpack v5 implementation for node.js, with extension points",

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

@@ -100,1 +100,87 @@

})
test('encoding error wrapped', function(t) {
t.plan(1)
var pack = msgpack()
, encoder = pack.encoder()
, data = new MyType()
function MyType() {
}
function mytypeEncode() {
throw new Error('muahha')
}
function mytypeDecode() {
}
pack.register(0x42, MyType, mytypeEncode, mytypeDecode)
encoder.on('error', function(err) {
t.equal(err.message, 'muahha')
})
encoder.end(data)
})
test('decoding error wrapped', function(t) {
t.plan(1)
var pack = msgpack()
, encoder = pack.encoder()
, decoder = pack.decoder()
, data = new MyType()
function MyType() {
}
function mytypeEncode() {
return new Buffer(0)
}
function mytypeDecode() {
throw new Error('muahha')
}
pack.register(0x42, MyType, mytypeEncode, mytypeDecode)
decoder.on('error', function(err) {
t.equal(err.message, 'muahha')
})
encoder.end(data)
encoder.pipe(decoder)
})
test('decoding error wrapped', function(t) {
t.plan(1)
var pack = msgpack()
, encoder = pack.encoder({ header: false })
, decoder = pack.decoder({ header: false })
, data = new MyType()
function MyType() {
}
function mytypeEncode() {
return new Buffer(0)
}
function mytypeDecode() {
throw new Error('muahha')
}
pack.register(0x42, MyType, mytypeEncode, mytypeDecode)
decoder.on('error', function(err) {
t.equal(err.message, 'muahha')
})
encoder.end(data)
encoder.pipe(decoder)
})
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