Socket
Socket
Sign inDemoInstall

bufio

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bufio - npm Package Compare versions

Comparing version 1.0.6 to 1.0.7

165

lib/encoding.js

@@ -60,3 +60,5 @@ /*!

const lo = readU32(data, off);
check((hi & 0xffe00000) === 0, off, 'Number exceeds 2^53-1');
return hi * 0x100000000 + lo;

@@ -68,3 +70,5 @@ }

const lo = readU32(data, off);
check((hi & 0xffe00000) === 0, off, 'Number exceeds 2^53-1');
return hi * 0x100000000 + lo;

@@ -75,7 +79,7 @@ }

return (data[off++]
+ data[off++] * 0x100
+ data[off++] * 0x10000
+ data[off++] * 0x1000000
+ data[off++] * 0x100000000
+ data[off] * 0x10000000000);
+ data[off++] * 0x100
+ data[off++] * 0x10000
+ data[off++] * 0x1000000
+ data[off++] * 0x100000000
+ data[off] * 0x10000000000);
}

@@ -85,6 +89,6 @@

return (data[off++]
+ data[off++] * 0x100
+ data[off++] * 0x10000
+ data[off++] * 0x1000000
+ data[off] * 0x100000000);
+ data[off++] * 0x100
+ data[off++] * 0x10000
+ data[off++] * 0x1000000
+ data[off] * 0x100000000);
}

@@ -94,5 +98,5 @@

return (data[off++]
+ data[off++] * 0x100
+ data[off++] * 0x10000
+ data[off] * 0x1000000);
+ data[off++] * 0x100
+ data[off++] * 0x10000
+ data[off] * 0x1000000);
}

@@ -102,4 +106,4 @@

return (data[off++]
+ data[off++] * 0x100
+ data[off] * 0x10000);
+ data[off++] * 0x100
+ data[off] * 0x10000);
}

@@ -145,3 +149,5 @@

const lo = readU32BE(data, off + 4);
check((hi & 0xffe00000) === 0, off, 'Number exceeds 2^53-1');
return hi * 0x100000000 + lo;

@@ -153,3 +159,5 @@ }

const lo = readU32BE(data, off + 3);
check((hi & 0xffe00000) === 0, off, 'Number exceeds 2^53-1');
return hi * 0x100000000 + lo;

@@ -160,7 +168,7 @@ }

return (data[off++] * 0x10000000000
+ data[off++] * 0x100000000
+ data[off++] * 0x1000000
+ data[off++] * 0x10000
+ data[off++] * 0x100
+ data[off]);
+ data[off++] * 0x100000000
+ data[off++] * 0x1000000
+ data[off++] * 0x10000
+ data[off++] * 0x100
+ data[off]);
}

@@ -170,6 +178,6 @@

return (data[off++] * 0x100000000
+ data[off++] * 0x1000000
+ data[off++] * 0x10000
+ data[off++] * 0x100
+ data[off]);
+ data[off++] * 0x1000000
+ data[off++] * 0x10000
+ data[off++] * 0x100
+ data[off]);
}

@@ -179,5 +187,5 @@

return (data[off++] * 0x1000000
+ data[off++] * 0x10000
+ data[off++] * 0x100
+ data[off]);
+ data[off++] * 0x10000
+ data[off++] * 0x100
+ data[off]);
}

@@ -187,4 +195,4 @@

return (data[off++] * 0x10000
+ data[off++] * 0x100
+ data[off]);
+ data[off++] * 0x100
+ data[off]);
}

@@ -226,3 +234,5 @@

const lo = readU32(data, off);
check(isSafe(hi, lo), 'Number exceeds 2^53-1');
return hi * 0x100000000 + lo;

@@ -234,3 +244,5 @@ }

const lo = readU32(data, off);
check(isSafe(hi, lo), 'Number exceeds 2^53-1');
return hi * 0x100000000 + lo;

@@ -243,6 +255,6 @@ }

return (data[off++]
+ data[off++] * 0x100
+ data[off++] * 0x10000
+ data[off] * 0x1000000
+ (val | (val & 0x8000) * 0x1fffe) * 0x100000000);
+ data[off++] * 0x100
+ data[off++] * 0x10000
+ data[off] * 0x1000000
+ (val | (val & 0x8000) * 0x1fffe) * 0x100000000);
}

@@ -252,6 +264,6 @@

return (data[off++]
+ data[off++] * 0x100
+ data[off++] * 0x10000
+ data[off++] * 0x1000000
+ (data[off] | (data[off] & 0x80) * 0x1fffffe) * 0x100000000);
+ data[off++] * 0x100
+ data[off++] * 0x10000
+ data[off++] * 0x1000000
+ (data[off] | (data[off] & 0x80) * 0x1fffffe) * 0x100000000);
}

@@ -261,5 +273,5 @@

return (data[off++]
+ data[off++] * 0x100
+ data[off++] * 0x10000
+ (data[off] << 24));
+ data[off++] * 0x100
+ data[off++] * 0x10000
+ (data[off] << 24));
}

@@ -269,4 +281,5 @@

const val = (data[off++]
+ data[off++] * 0x100
+ data[off] * 0x10000);
+ data[off++] * 0x100
+ data[off] * 0x10000);
return val | (val & 0x800000) * 0x1fe;

@@ -315,3 +328,5 @@ }

const lo = readU32BE(data, off + 4);
check(isSafe(hi, lo), 'Number exceeds 2^53-1');
return hi * 0x100000000 + lo;

@@ -323,3 +338,5 @@ }

const lo = readU32BE(data, off + 3);
check(isSafe(hi, lo), 'Number exceeds 2^53-1');
return hi * 0x100000000 + lo;

@@ -332,6 +349,6 @@ }

return ((val | (val & 0x8000) * 0x1fffe) * 0x100000000
+ data[off++] * 0x1000000
+ data[off++] * 0x10000
+ data[off++] * 0x100
+ data[off]);
+ data[off++] * 0x1000000
+ data[off++] * 0x10000
+ data[off++] * 0x100
+ data[off]);
}

@@ -343,6 +360,6 @@

return ((val | (val & 0x80) * 0x1fffffe) * 0x100000000
+ data[off++] * 0x1000000
+ data[off++] * 0x10000
+ data[off++] * 0x100
+ data[off]);
+ data[off++] * 0x1000000
+ data[off++] * 0x10000
+ data[off++] * 0x100
+ data[off]);
}

@@ -352,5 +369,5 @@

return ((data[off++] << 24)
+ data[off++] * 0x10000
+ data[off++] * 0x100
+ data[off]);
+ data[off++] * 0x10000
+ data[off++] * 0x100
+ data[off]);
}

@@ -360,4 +377,4 @@

const val = (data[off++] * 0x10000
+ data[off++] * 0x100
+ data[off]);
+ data[off++] * 0x100
+ data[off]);

@@ -503,2 +520,3 @@ return val | (val & 0x800000) * 0x1fe;

dst[off++] = num;
return off;

@@ -515,2 +533,3 @@ }

dst[off++] = num;
return off;

@@ -521,4 +540,6 @@ }

enforce(Number.isSafeInteger(num), 'num', 'integer');
dst[off++] = num;
dst[off++] = num >>> 8;
return off;

@@ -529,3 +550,5 @@ }

enforce(Number.isSafeInteger(num), 'num', 'integer');
dst[off] = num;
return off + 1;

@@ -608,2 +631,3 @@ }

enforce(Number.isSafeInteger(num), 'num', 'integer');
dst[off + 3] = num;

@@ -616,2 +640,3 @@ num >>>= 8;

dst[off] = num;
return off + 4;

@@ -622,2 +647,3 @@ }

enforce(Number.isSafeInteger(num), 'num', 'integer');
dst[off + 2] = num;

@@ -628,2 +654,3 @@ num >>>= 8;

dst[off] = num;
return off + 3;

@@ -634,4 +661,6 @@ }

enforce(Number.isSafeInteger(num), 'num', 'integer');
dst[off++] = num >>> 8;
dst[off++] = num;
return off;

@@ -756,3 +785,5 @@ }

enforce(isNumber(num), 'num', 'number');
F64_ARRAY[0] = num;
dst[off++] = F648_ARRAY[0];

@@ -766,2 +797,3 @@ dst[off++] = F648_ARRAY[1];

dst[off++] = F648_ARRAY[7];
return off;

@@ -772,3 +804,5 @@ }

enforce(isNumber(num), 'num', 'number');
F64_ARRAY[0] = num;
dst[off++] = F648_ARRAY[7];

@@ -782,2 +816,3 @@ dst[off++] = F648_ARRAY[6];

dst[off++] = F648_ARRAY[0];
return off;

@@ -788,3 +823,5 @@ }

enforce(isNumber(num), 'num', 'number');
F32_ARRAY[0] = num;
dst[off++] = F328_ARRAY[0];

@@ -794,2 +831,3 @@ dst[off++] = F328_ARRAY[1];

dst[off++] = F328_ARRAY[3];
return off;

@@ -800,3 +838,5 @@ }

enforce(isNumber(num), 'num', 'number');
F32_ARRAY[0] = num;
dst[off++] = F328_ARRAY[3];

@@ -806,2 +846,3 @@ dst[off++] = F328_ARRAY[2];

dst[off++] = F328_ARRAY[0];
return off;

@@ -871,2 +912,3 @@ }

dst[off++] = 0xff;
return writeU64(dst, num, off);

@@ -898,2 +940,3 @@ }

const ch = data[off++];
size += 1;

@@ -926,4 +969,6 @@

tmp[len] = (num & 0x7f) | (len ? 0x80 : 0x00);
if (num <= 0x7f)
break;
// num = (num >>> 7) - 1;

@@ -950,4 +995,6 @@ num = ((num - (num % 0x80)) / 0x80) - 1;

size += 1;
if (num <= 0x7f)
break;
// num = (num >>> 7) - 1;

@@ -983,4 +1030,6 @@ num = ((num - (num % 0x80)) / 0x80) - 1;

const buf = Buffer.allocUnsafe(size);
const buf = Buffer.allocUnsafeSlow(size);
data.copy(buf, 0, off, off + size);
return buf;

@@ -1038,4 +1087,6 @@ }

const buf = Buffer.allocUnsafe(size);
const buf = Buffer.allocUnsafeSlow(size);
data.copy(buf, 0);
return buf;

@@ -1054,3 +1105,3 @@ }

const size = a.length + b.length;
const buf = Buffer.allocUnsafe(size);
const buf = Buffer.allocUnsafeSlow(size);

@@ -1057,0 +1108,0 @@ a.copy(buf, 0);

@@ -16,4 +16,6 @@ /*!

const err = new TypeError(`'${name}' must be a(n) ${type}.`);
if (Error.captureStackTrace)
Error.captureStackTrace(err, enforce);
throw err;

@@ -20,0 +22,0 @@ }

@@ -142,3 +142,4 @@ /*!

const ret = Buffer.allocUnsafe(size);
const ret = Buffer.allocUnsafeSlow(size);
data.copy(ret, 0, start, end);

@@ -167,4 +168,7 @@

this.check(1);
const ret = this.data[this.offset];
this.offset += 1;
return ret;

@@ -180,4 +184,7 @@ }

this.check(2);
const ret = encoding.readU16(this.data, this.offset);
this.offset += 2;
return ret;

@@ -193,4 +200,7 @@ }

this.check(2);
const ret = encoding.readU16BE(this.data, this.offset);
this.offset += 2;
return ret;

@@ -206,4 +216,7 @@ }

this.check(3);
const ret = encoding.readU24(this.data, this.offset);
this.offset += 3;
return ret;

@@ -219,4 +232,7 @@ }

this.check(3);
const ret = encoding.readU24BE(this.data, this.offset);
this.offset += 3;
return ret;

@@ -232,4 +248,7 @@ }

this.check(4);
const ret = encoding.readU32(this.data, this.offset);
this.offset += 4;
return ret;

@@ -245,4 +264,7 @@ }

this.check(4);
const ret = encoding.readU32BE(this.data, this.offset);
this.offset += 4;
return ret;

@@ -258,4 +280,7 @@ }

this.check(5);
const ret = encoding.readU40(this.data, this.offset);
this.offset += 5;
return ret;

@@ -271,4 +296,7 @@ }

this.check(5);
const ret = encoding.readU40BE(this.data, this.offset);
this.offset += 5;
return ret;

@@ -284,4 +312,7 @@ }

this.check(6);
const ret = encoding.readU48(this.data, this.offset);
this.offset += 6;
return ret;

@@ -297,4 +328,7 @@ }

this.check(6);
const ret = encoding.readU48BE(this.data, this.offset);
this.offset += 6;
return ret;

@@ -310,4 +344,7 @@ }

this.check(7);
const ret = encoding.readU56(this.data, this.offset);
this.offset += 7;
return ret;

@@ -323,4 +360,7 @@ }

this.check(7);
const ret = encoding.readU56BE(this.data, this.offset);
this.offset += 7;
return ret;

@@ -337,4 +377,7 @@ }

this.check(8);
const ret = encoding.readU64(this.data, this.offset);
this.offset += 8;
return ret;

@@ -351,4 +394,7 @@ }

this.check(8);
const ret = encoding.readU64BE(this.data, this.offset);
this.offset += 8;
return ret;

@@ -364,4 +410,7 @@ }

this.check(1);
const ret = encoding.readI8(this.data, this.offset);
this.offset += 1;
return ret;

@@ -377,4 +426,7 @@ }

this.check(2);
const ret = encoding.readI16(this.data, this.offset);
this.offset += 2;
return ret;

@@ -390,4 +442,7 @@ }

this.check(2);
const ret = encoding.readI16BE(this.data, this.offset);
this.offset += 2;
return ret;

@@ -403,4 +458,7 @@ }

this.check(3);
const ret = encoding.readI24(this.data, this.offset);
this.offset += 3;
return ret;

@@ -416,4 +474,7 @@ }

this.check(3);
const ret = encoding.readI24BE(this.data, this.offset);
this.offset += 3;
return ret;

@@ -429,4 +490,7 @@ }

this.check(4);
const ret = encoding.readI32(this.data, this.offset);
this.offset += 4;
return ret;

@@ -442,4 +506,7 @@ }

this.check(4);
const ret = encoding.readI32BE(this.data, this.offset);
this.offset += 4;
return ret;

@@ -455,4 +522,7 @@ }

this.check(5);
const ret = encoding.readI40(this.data, this.offset);
this.offset += 5;
return ret;

@@ -468,4 +538,7 @@ }

this.check(5);
const ret = encoding.readI40BE(this.data, this.offset);
this.offset += 5;
return ret;

@@ -481,4 +554,7 @@ }

this.check(6);
const ret = encoding.readI48(this.data, this.offset);
this.offset += 6;
return ret;

@@ -494,4 +570,7 @@ }

this.check(6);
const ret = encoding.readI48BE(this.data, this.offset);
this.offset += 6;
return ret;

@@ -507,4 +586,7 @@ }

this.check(7);
const ret = encoding.readI56(this.data, this.offset);
this.offset += 7;
return ret;

@@ -520,4 +602,7 @@ }

this.check(7);
const ret = encoding.readI56BE(this.data, this.offset);
this.offset += 7;
return ret;

@@ -534,4 +619,7 @@ }

this.check(8);
const ret = encoding.readI64(this.data, this.offset);
this.offset += 8;
return ret;

@@ -548,4 +636,7 @@ }

this.check(8);
const ret = encoding.readI64BE(this.data, this.offset);
this.offset += 8;
return ret;

@@ -561,4 +652,7 @@ }

this.check(4);
const ret = encoding.readFloat(this.data, this.offset);
this.offset += 4;
return ret;

@@ -574,4 +668,7 @@ }

this.check(4);
const ret = encoding.readFloatBE(this.data, this.offset);
this.offset += 4;
return ret;

@@ -587,4 +684,7 @@ }

this.check(8);
const ret = encoding.readDouble(this.data, this.offset);
this.offset += 8;
return ret;

@@ -600,4 +700,7 @@ }

this.check(8);
const ret = encoding.readDoubleBE(this.data, this.offset);
this.offset += 8;
return ret;

@@ -613,3 +716,5 @@ }

const {size, value} = encoding.readVarint(this.data, this.offset);
this.offset += size;
return value;

@@ -625,3 +730,5 @@ }

const {size, value} = encoding.readVarint2(this.data, this.offset);
this.offset += size;
return value;

@@ -646,6 +753,7 @@ }

let ret;
if (this.zeroCopy || zeroCopy) {
ret = this.data.slice(this.offset, this.offset + size);
} else {
ret = Buffer.allocUnsafe(size);
ret = Buffer.allocUnsafeSlow(size);
this.data.copy(ret, 0, this.offset, this.offset + size);

@@ -683,4 +791,4 @@ }

const data = this.data.slice(0, this.offset + size);
const br = new this.constructor(data);
const br = new this.constructor(data);
br.offset = this.offset;

@@ -786,3 +894,4 @@

createChecksum(hash) {
enforce(typeof hash === 'function', 'hash', 'function');
if (!hash || typeof hash.digest !== 'function')
enforce(typeof hash === 'function', 'hash', 'function');

@@ -795,4 +904,5 @@ let start = 0;

const data = this.data.slice(start, this.offset);
const raw = hash.digest ? hash.digest(data) : hash(data);
return encoding.readU32(hash(data), 0);
return encoding.readU32(raw, 0);
}

@@ -799,0 +909,0 @@

@@ -65,3 +65,3 @@ /*!

this.data = Buffer.allocUnsafe(options);
this.data = Buffer.allocUnsafeSlow(options);
this.offset = 0;

@@ -83,6 +83,8 @@

if (!POOL)
POOL = Buffer.allocUnsafe(POOL_SIZE);
POOL = Buffer.allocUnsafeSlow(POOL_SIZE);
const bw = new StaticWriter();
bw.data = POOL.slice(0, size);
return bw;

@@ -563,4 +565,6 @@ }

enforce(Buffer.isBuffer(value), 'value', 'buffer');
this.check(value.length);
this.offset += value.copy(this.data, this.offset);
return this;

@@ -576,4 +580,6 @@ }

enforce(Buffer.isBuffer(value), 'value', 'buffer');
this.writeVarint(value.length);
this.writeBytes(value);
return this;

@@ -618,2 +624,3 @@ }

const size = Buffer.byteLength(value, enc);
this.check(size);

@@ -638,5 +645,8 @@

}
enforce(value.length === 64, 'value', '32-byte hash');
this.check(32);
this.offset += this.data.write(value, this.offset, 'hex');
return this;

@@ -690,3 +700,4 @@ }

writeChecksum(hash) {
enforce(typeof hash === 'function', 'hash', 'function');
if (!hash || typeof hash.digest !== 'function')
enforce(typeof hash === 'function', 'hash', 'function');

@@ -696,4 +707,5 @@ this.check(4);

const data = this.data.slice(0, this.offset);
const raw = hash.digest ? hash.digest(data) : hash(data);
hash(data).copy(this.data, this.offset, 0, 4);
raw.copy(this.data, this.offset, 0, 4);

@@ -700,0 +712,0 @@ this.offset += 4;

@@ -85,3 +85,5 @@ /*!

: new StaticWriter(size);
this.write(bw, extra);
return bw.render();

@@ -92,3 +94,5 @@ }

const br = new BufferReader(data);
this.read(br, extra);
return this;

@@ -95,0 +99,0 @@ }

@@ -81,3 +81,3 @@ /*!

render() {
const data = Buffer.allocUnsafe(this.offset);
const data = Buffer.allocUnsafeSlow(this.offset);

@@ -748,4 +748,7 @@ let off = 0;

}
enforce(value.length === 64, 'value', '32-byte hash');
this.writeString(value, 'hex');
return this;

@@ -801,5 +804,10 @@ }

writeChecksum(hash) {
if (hash && typeof hash.digest === 'function')
hash = hash.digest.bind(hash);
enforce(typeof hash === 'function', 'hash', 'function');
this.offset += 4;
this.ops.push(new FunctionOp(CHECKSUM, hash));
return this;

@@ -806,0 +814,0 @@ }

{
"name": "bufio",
"version": "1.0.6",
"version": "1.0.7",
"description": "Buffer and serialization utilities for javascript",

@@ -5,0 +5,0 @@ "keywords": [

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