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.0.0 to 1.0.1

13

index.js

@@ -323,4 +323,6 @@

var result = {}
, key
for (i = 0; i < length; i++) {
result[decode(buf)] = decode(buf)
key = decode(buf)
result[key] = decode(buf)
}

@@ -355,3 +357,10 @@ return result

return bl(acc)
var result = acc.reduce(function(list, buf) {
// TODO remove the slicing after
// https://github.com/rvagg/bl/pull/12
// gets merged
return list.append(buf.slice(0, buf.length))
}, bl())
return result
}

@@ -358,0 +367,0 @@

2

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

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

@@ -14,3 +14,3 @@

function mytipeEncode(obj) {
function mytypeEncode(obj) {
var buf = new Buffer(1)

@@ -21,7 +21,7 @@ buf.writeUInt8(obj.data, 0)

function mytipeDecode(data) {
function mytypeDecode(data) {
return new MyType(data.readUInt8(0))
}
encoder.register(0x42, MyType, mytipeEncode, mytipeDecode)
encoder.register(0x42, MyType, mytypeEncode, mytypeDecode)

@@ -70,3 +70,3 @@ all.push(new MyType(0))

function mytipeEncode(obj) {
function mytypeEncode(obj) {
var buf = new Buffer(2)

@@ -77,7 +77,7 @@ buf.writeUInt16BE(obj.data, 0)

function mytipeDecode(data) {
function mytypeDecode(data) {
return new MyType(data.readUInt16BE(0))
}
encoder.register(0x42, MyType, mytipeEncode, mytipeDecode)
encoder.register(0x42, MyType, mytypeEncode, mytypeDecode)

@@ -126,3 +126,3 @@ all.push(new MyType(0))

function mytipeEncode(obj) {
function mytypeEncode(obj) {
var buf = new Buffer(4)

@@ -133,7 +133,7 @@ buf.writeUInt32BE(obj.data, 0)

function mytipeDecode(data) {
function mytypeDecode(data) {
return new MyType(data.readUInt32BE(0))
}
encoder.register(0x44, MyType, mytipeEncode, mytipeDecode)
encoder.register(0x44, MyType, mytypeEncode, mytypeDecode)

@@ -182,3 +182,3 @@ all.push(new MyType(0))

function mytipeEncode(obj) {
function mytypeEncode(obj) {
var buf = new Buffer(8)

@@ -190,7 +190,7 @@ buf.writeUInt32BE(obj.data / 2, 0)

function mytipeDecode(data) {
function mytypeDecode(data) {
return new MyType(data.readUInt32BE(0) + data.readUInt32BE(4))
}
encoder.register(0x44, MyType, mytipeEncode, mytipeDecode)
encoder.register(0x44, MyType, mytypeEncode, mytypeDecode)

@@ -240,3 +240,3 @@ all.push(new MyType(2))

function mytipeEncode(obj) {
function mytypeEncode(obj) {
var buf = new Buffer(16)

@@ -250,7 +250,7 @@ buf.writeUInt32BE(obj.data / 4, 0)

function mytipeDecode(data) {
function mytypeDecode(data) {
return new MyType(data.readUInt32BE(0) + data.readUInt32BE(4) + data.readUInt32BE(8) + data.readUInt32BE(12))
}
encoder.register(0x46, MyType, mytipeEncode, mytipeDecode)
encoder.register(0x46, MyType, mytypeEncode, mytypeDecode)

@@ -292,1 +292,153 @@ all.push(new MyType(4))

})
test('encode/decode fixext inside a map', function(t) {
var encoder = msgpack()
, all = []
function MyType(data) {
this.data = data
}
function mytypeEncode(obj) {
var buf = new Buffer(4)
buf.writeUInt32BE(obj.data, 0)
console.log(buf);
return buf
}
function mytypeDecode(data) {
return new MyType(data.readUInt32BE(0))
}
encoder.register(0x42, MyType, mytypeEncode, mytypeDecode)
all.push({ ret: new MyType(42) })
all.forEach(function(orig) {
t.test('mirror test with a custom obj inside a map', function(t) {
var encoded = encoder.encode(orig)
console.log(encoded)
t.deepEqual(encoder.decode(encoded), orig, 'must stay the same')
t.end()
})
})
t.end()
})
test('encode/decode 8 bytes fixext data', function(t) {
var encoder = msgpack()
, all = []
function MyType(data) {
this.data = data
}
function mytypeEncode(obj) {
var buf = new Buffer(8)
buf.writeUInt32BE(obj.data / 2, 0)
buf.writeUInt32BE(obj.data / 2, 4)
return buf
}
function mytypeDecode(data) {
return new MyType(data.readUInt32BE(0) + data.readUInt32BE(4))
}
encoder.register(0x44, MyType, mytypeEncode, mytypeDecode)
all.push(new MyType(2))
all.push(new MyType(4))
all.push(new MyType(42))
all.forEach(function(orig) {
t.test('encoding a custom obj encoded as ' + orig.data, function(t) {
var buf = encoder.encode(orig)
t.equal(buf.length, 10, 'must have the right length')
t.equal(buf.readUInt8(0), 0xd7, 'must have the fixext header')
t.equal(buf.readUInt8(1), 0x44, 'must include the custom type id')
t.equal(buf.readUInt32BE(2) + buf.readUInt32BE(6), orig.data, 'must decode correctly')
t.end()
})
t.test('decoding a custom obj encoded as ' + orig.data, function(t) {
var buf = new Buffer(10)
buf[0] = 0xd7
buf[1] = 0x44
buf.writeUInt32BE(orig.data / 2, 2)
buf.writeUInt32BE(orig.data / 2, 6)
t.deepEqual(encoder.decode(buf), orig, 'must decode correctly')
t.type(encoder.decode(buf), MyType, 'must have the correct prototype')
t.end()
})
t.test('mirror test with a custom obj containing ' + orig.data, function(t) {
t.deepEqual(encoder.decode(encoder.encode(orig)), orig, 'must stay the same')
t.end()
})
})
t.end()
})
test('encode/decode 16 bytes fixext data', function(t) {
var encoder = msgpack()
, all = []
function MyType(data) {
this.data = data
}
function mytypeEncode(obj) {
var buf = new Buffer(16)
buf.writeUInt32BE(obj.data / 4, 0)
buf.writeUInt32BE(obj.data / 4, 4)
buf.writeUInt32BE(obj.data / 4, 8)
buf.writeUInt32BE(obj.data / 4, 12)
return buf
}
function mytypeDecode(data) {
return new MyType(data.readUInt32BE(0) + data.readUInt32BE(4) + data.readUInt32BE(8) + data.readUInt32BE(12))
}
encoder.register(0x46, MyType, mytypeEncode, mytypeDecode)
all.push(new MyType(4))
all.push(new MyType(8))
all.push(new MyType(44))
all.forEach(function(orig) {
t.test('encoding a custom obj encoded as ' + orig.data, function(t) {
var buf = encoder.encode(orig)
t.equal(buf.length, 18, 'must have the right length')
t.equal(buf.readUInt8(0), 0xd8, 'must have the fixext header')
t.equal(buf.readUInt8(1), 0x46, 'must include the custom type id')
t.equal(buf.readUInt32BE(2) + buf.readUInt32BE(6) + buf.readUInt32BE(10) + buf.readUInt32BE(14), orig.data, 'must decode correctly')
t.end()
})
t.test('decoding a custom obj encoded as ' + orig.data, function(t) {
var buf = new Buffer(18)
buf[0] = 0xd8
buf[1] = 0x46
buf.writeUInt32BE(orig.data / 4, 2)
buf.writeUInt32BE(orig.data / 4, 6)
buf.writeUInt32BE(orig.data / 4, 10)
buf.writeUInt32BE(orig.data / 4, 14)
t.type(encoder.decode(buf), MyType, 'must have the correct prototype')
t.deepEqual(encoder.decode(buf), orig, 'must decode correctly')
t.end()
})
t.test('mirror test with a custom obj containing ' + orig.data, function(t) {
t.deepEqual(encoder.decode(encoder.encode(orig)), orig, 'must stay the same')
t.end()
})
})
t.end()
})

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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