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

what-the-pack

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

what-the-pack - npm Package Compare versions

Comparing version 1.1.3 to 1.1.4

9

benchmark.js

@@ -0,1 +1,3 @@

/* eslint-disable no-console */
const Benchmark = require('benchmark');

@@ -38,9 +40,2 @@ const suite = new Benchmark.Suite;

}
const map = (length) => {
const result = {};
for (let i = 0; i < length; i++) {
result[i + ''] = i;
}
return result;
}

@@ -47,0 +42,0 @@ const medium = {

@@ -62,3 +62,5 @@ /* eslint-disable no-console */

case 'string':
if (value.length < 32) { // < 32, fixstr
length = Buffer.byteLength(value);
if (length < 32) { // < 32, fixstr
length = 0;
for (let i = 0, c = 0, l = value.length; i < l; i += 1) {

@@ -98,27 +100,23 @@ c = value.charCodeAt(i);

}
break;
} else { // > 32, str8, str16, str32
length = Buffer.byteLength(value);
if (length < 256) { // str8
allocator.buffer[allocator.offset += 1] = 217;
allocator.buffer[allocator.offset += 1] = length;
allocator.buffer.write(value, allocator.offset += 1, length, 'utf8');
allocator.offset += length - 1;
} else if (length < 65536) { // str16
allocator.buffer[allocator.offset += 1] = 218;
allocator.buffer[allocator.offset += 1] = length >> 8;
allocator.buffer[allocator.offset += 1] = length;
allocator.buffer.write(value, allocator.offset += 1, length, 'utf8');
allocator.offset += length - 1;
} else if (length < 4294967296) { // str32
allocator.buffer[allocator.offset += 1] = 219;
allocator.buffer[allocator.offset += 1] = length >> 24;
allocator.buffer[allocator.offset += 1] = length >> 16;
allocator.buffer[allocator.offset += 1] = length >> 8;
allocator.buffer[allocator.offset += 1] = length;
allocator.buffer.write(value, allocator.offset += 1, length, 'utf8');
allocator.offset += length - 1;
} else {
throw Error('Max supported string length (4294967296) exceeded, encoding failure.');
}
} else if (length < 256) { // str8
allocator.buffer[allocator.offset += 1] = 217;
allocator.buffer[allocator.offset += 1] = length;
allocator.buffer.write(value, allocator.offset += 1, length, 'utf8');
allocator.offset += length - 1;
} else if (length < 65536) { // str16
allocator.buffer[allocator.offset += 1] = 218;
allocator.buffer[allocator.offset += 1] = length >> 8;
allocator.buffer[allocator.offset += 1] = length;
allocator.buffer.write(value, allocator.offset += 1, length, 'utf8');
allocator.offset += length - 1;
} else if (length < 4294967296) { // str32
allocator.buffer[allocator.offset += 1] = 219;
allocator.buffer[allocator.offset += 1] = length >> 24;
allocator.buffer[allocator.offset += 1] = length >> 16;
allocator.buffer[allocator.offset += 1] = length >> 8;
allocator.buffer[allocator.offset += 1] = length;
allocator.buffer.write(value, allocator.offset += 1, length, 'utf8');
allocator.offset += length - 1;
} else {
throw Error('Max supported string length (4294967296) exceeded, encoding failure.');
}

@@ -125,0 +123,0 @@ break;

{
"name": "what-the-pack",
"version": "1.1.3",
"version": "1.1.4",
"description": "The fastest MessagePack implementation in JS",

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

"notepack.io": "^2.1.3",
"rollup": "^0.66.6",
"rollup": "^0.67.4",
"rollup-plugin-commonjs": "^9.2.0",
"rollup-plugin-node-resolve": "^3.4.0",
"rollup-plugin-node-resolve": "^4.0.0",
"rollup-plugin-terser": "^3.0.0"

@@ -23,0 +23,0 @@ },

@@ -9,3 +9,3 @@ const { reallocate, encode, decode } = require('./index');

test('fixstr', () => {
[ '', 'hello' ].forEach((value) => expect(decode(encode(value))).toBe(value));
[ '', 'hello', 'WALL·E – Typeset in the Future'].forEach((value) => expect(decode(encode(value))).toBe(value));
});

@@ -209,10 +209,2 @@ it('str 8', () => {

const map = (length) => {
const result = {};
for (let i = 0; i < length; i++) {
result[i + ''] = i;
}
return result;
}
const large = {

@@ -219,0 +211,0 @@ unsigned: [1, 2, 3, 4, { b: { c: [128, 256, 65536, 4294967296] } }],

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