Comparing version 1.0.7 to 1.1.0
@@ -111,2 +111,4 @@ /*! | ||
exports.readU = _readn(encoding.readU); | ||
exports.readBigU64 = _read(encoding.readBigU64, 8); | ||
exports.readBigU56 = _read(encoding.readBigU56, 7); | ||
exports.readU64 = _read(encoding.readU64, 8); | ||
@@ -122,2 +124,4 @@ exports.readU56 = _read(encoding.readU56, 7); | ||
exports.readUBE = _readn(encoding.readUBE); | ||
exports.readBigU64BE = _read(encoding.readBigU64BE, 8); | ||
exports.readBigU56BE = _read(encoding.readBigU56BE, 7); | ||
exports.readU64BE = _read(encoding.readU64BE, 8); | ||
@@ -132,2 +136,4 @@ exports.readU56BE = _read(encoding.readU56BE, 7); | ||
exports.readI = _readn(encoding.readI); | ||
exports.readBigI64 = _read(encoding.readBigI64, 8); | ||
exports.readBigI56 = _read(encoding.readBigI56, 7); | ||
exports.readI64 = _read(encoding.readI64, 8); | ||
@@ -143,2 +149,4 @@ exports.readI56 = _read(encoding.readI56, 7); | ||
exports.readIBE = _readn(encoding.readIBE); | ||
exports.readBigI64BE = _read(encoding.readBigI64BE, 8); | ||
exports.readBigI56BE = _read(encoding.readBigI56BE, 7); | ||
exports.readI64BE = _read(encoding.readI64BE, 8); | ||
@@ -158,2 +166,4 @@ exports.readI56BE = _read(encoding.readI56BE, 7); | ||
exports.writeU = _writen(encoding.writeU); | ||
exports.writeBigU64 = _write(encoding.writeBigU64, 8); | ||
exports.writeBigU56 = _write(encoding.writeBigU56, 7); | ||
exports.writeU64 = _write(encoding.writeU64, 8); | ||
@@ -169,2 +179,4 @@ exports.writeU56 = _write(encoding.writeU56, 7); | ||
exports.writeUBE = _writen(encoding.writeUBE); | ||
exports.writeBigU64BE = _write(encoding.writeBigU64BE, 8); | ||
exports.writeBigU56BE = _write(encoding.writeBigU56BE, 7); | ||
exports.writeU64BE = _write(encoding.writeU64BE, 8); | ||
@@ -179,2 +191,4 @@ exports.writeU56BE = _write(encoding.writeU56BE, 7); | ||
exports.writeI = _writen(encoding.writeI); | ||
exports.writeBigI64 = _write(encoding.writeBigI64, 8); | ||
exports.writeBigI56 = _write(encoding.writeBigI56, 7); | ||
exports.writeI64 = _write(encoding.writeI64, 8); | ||
@@ -190,2 +204,4 @@ exports.writeI56 = _write(encoding.writeI56, 7); | ||
exports.writeIBE = _writen(encoding.writeIBE); | ||
exports.writeBigI64BE = _write(encoding.writeBigI64BE, 8); | ||
exports.writeBigI56BE = _write(encoding.writeBigI56BE, 7); | ||
exports.writeI64BE = _write(encoding.writeI64BE, 8); | ||
@@ -192,0 +208,0 @@ exports.writeI56BE = _write(encoding.writeI56BE, 7); |
@@ -57,2 +57,16 @@ /*! | ||
function readBigU64(data, off) { | ||
const hi = readU32(data, off + 4); | ||
const lo = readU32(data, off); | ||
return (BigInt(hi) << BigInt(32)) | BigInt(lo); | ||
} | ||
function readBigU56(data, off) { | ||
const hi = readU24(data, off + 4); | ||
const lo = readU32(data, off); | ||
return (BigInt(hi) << BigInt(32)) | BigInt(lo); | ||
} | ||
function readU64(data, off) { | ||
@@ -141,2 +155,16 @@ const hi = readU32(data, off + 4); | ||
function readBigU64BE(data, off) { | ||
const hi = readU32BE(data, off); | ||
const lo = readU32BE(data, off + 4); | ||
return (BigInt(hi) << BigInt(32)) | BigInt(lo); | ||
} | ||
function readBigU56BE(data, off) { | ||
const hi = readU24BE(data, off); | ||
const lo = readU32BE(data, off + 3); | ||
return (BigInt(hi) << BigInt(32)) | BigInt(lo); | ||
} | ||
function readU64BE(data, off) { | ||
@@ -221,2 +249,16 @@ const hi = readU32BE(data, off); | ||
function readBigI64(data, off) { | ||
const hi = readI32(data, off + 4); | ||
const lo = readU32(data, off); | ||
return (BigInt(hi) << BigInt(32)) | BigInt(lo); | ||
} | ||
function readBigI56(data, off) { | ||
const hi = readI24(data, off + 4); | ||
const lo = readU32(data, off); | ||
return (BigInt(hi) << BigInt(32)) | BigInt(lo); | ||
} | ||
function readI64(data, off) { | ||
@@ -310,2 +352,16 @@ const hi = readI32(data, off + 4); | ||
function readBigI64BE(data, off) { | ||
const hi = readI32BE(data, off); | ||
const lo = readU32BE(data, off + 4); | ||
return (BigInt(hi) << BigInt(32)) | BigInt(lo); | ||
} | ||
function readBigI56BE(data, off) { | ||
const hi = readI24BE(data, off); | ||
const lo = readU32BE(data, off + 3); | ||
return (BigInt(hi) << BigInt(32)) | BigInt(lo); | ||
} | ||
function readI64BE(data, off) { | ||
@@ -445,2 +501,32 @@ const hi = readI32BE(data, off); | ||
function writeBigU64(dst, num, off) { | ||
// eslint-disable-next-line valid-typeof | ||
enforce(typeof num === 'bigint', 'num', 'bigint'); | ||
num &= BigInt(0xffffffffffffffff); | ||
const hi = Number(num >> BigInt(32)); | ||
const lo = Number(num & BigInt(0xffffffff)); | ||
off = writeU32(dst, lo, off); | ||
off = writeU32(dst, hi, off); | ||
return off; | ||
} | ||
function writeBigU56(dst, num, off) { | ||
// eslint-disable-next-line valid-typeof | ||
enforce(typeof num === 'bigint', 'num', 'bigint'); | ||
num &= BigInt(0xffffffffffffff); | ||
const hi = Number(num >> BigInt(32)); | ||
const lo = Number(num & BigInt(0xffffffff)); | ||
off = writeU32(dst, lo, off); | ||
off = writeU24(dst, hi, off); | ||
return off; | ||
} | ||
function writeU64(dst, num, off) { | ||
@@ -561,2 +647,32 @@ enforce(Number.isSafeInteger(num), 'num', 'integer'); | ||
function writeBigU64BE(dst, num, off) { | ||
// eslint-disable-next-line valid-typeof | ||
enforce(typeof num === 'bigint', 'num', 'bigint'); | ||
num &= BigInt(0xffffffffffffffff); | ||
const hi = Number(num >> BigInt(32)); | ||
const lo = Number(num & BigInt(0xffffffff)); | ||
off = writeU32BE(dst, hi, off); | ||
off = writeU32BE(dst, lo, off); | ||
return off; | ||
} | ||
function writeBigU56BE(dst, num, off) { | ||
// eslint-disable-next-line valid-typeof | ||
enforce(typeof num === 'bigint', 'num', 'bigint'); | ||
num &= BigInt(0xffffffffffffff); | ||
const hi = Number(num >> BigInt(32)); | ||
const lo = Number(num & BigInt(0xffffffff)); | ||
off = writeU24BE(dst, hi, off); | ||
off = writeU32BE(dst, lo, off); | ||
return off; | ||
} | ||
function writeU64BE(dst, num, off) { | ||
@@ -669,2 +785,10 @@ enforce(Number.isSafeInteger(num), 'num', 'integer'); | ||
function writeBigI64(dst, num, off) { | ||
return writeBigU64(dst, num, off); | ||
} | ||
function writeBigI56(dst, num, off) { | ||
return writeBigU56(dst, num, off); | ||
} | ||
function writeI64(dst, num, off) { | ||
@@ -729,2 +853,10 @@ return writeU64(dst, num, off); | ||
function writeBigI64BE(dst, num, off) { | ||
return writeBigU64BE(dst, num, off); | ||
} | ||
function writeBigI56BE(dst, num, off) { | ||
return writeBigU56BE(dst, num, off); | ||
} | ||
function writeI64BE(dst, num, off) { | ||
@@ -1204,2 +1336,4 @@ return writeU64BE(dst, num, off); | ||
exports.readU = readU; | ||
exports.readBigU64 = readBigU64; | ||
exports.readBigU56 = readBigU56; | ||
exports.readU64 = readU64; | ||
@@ -1215,2 +1349,4 @@ exports.readU56 = readU56; | ||
exports.readUBE = readUBE; | ||
exports.readBigU64BE = readBigU64BE; | ||
exports.readBigU56BE = readBigU56BE; | ||
exports.readU64BE = readU64BE; | ||
@@ -1225,2 +1361,4 @@ exports.readU56BE = readU56BE; | ||
exports.readI = readI; | ||
exports.readBigI64 = readBigI64; | ||
exports.readBigI56 = readBigI56; | ||
exports.readI64 = readI64; | ||
@@ -1236,2 +1374,4 @@ exports.readI56 = readI56; | ||
exports.readIBE = readIBE; | ||
exports.readBigI64BE = readBigI64BE; | ||
exports.readBigI56BE = readBigI56BE; | ||
exports.readI64BE = readI64BE; | ||
@@ -1251,2 +1391,4 @@ exports.readI56BE = readI56BE; | ||
exports.writeU = writeU; | ||
exports.writeBigU64 = writeBigU64; | ||
exports.writeBigU56 = writeBigU56; | ||
exports.writeU64 = writeU64; | ||
@@ -1262,2 +1404,4 @@ exports.writeU56 = writeU56; | ||
exports.writeUBE = writeUBE; | ||
exports.writeBigU64BE = writeBigU64BE; | ||
exports.writeBigU56BE = writeBigU56BE; | ||
exports.writeU64BE = writeU64BE; | ||
@@ -1272,2 +1416,4 @@ exports.writeU56BE = writeU56BE; | ||
exports.writeI = writeI; | ||
exports.writeBigI64 = writeBigI64; | ||
exports.writeBigI56 = writeBigI56; | ||
exports.writeI64 = writeI64; | ||
@@ -1283,2 +1429,4 @@ exports.writeI56 = writeI56; | ||
exports.writeIBE = writeIBE; | ||
exports.writeBigI64BE = writeBigI64BE; | ||
exports.writeBigI56BE = writeBigI56BE; | ||
exports.writeI64BE = writeI64BE; | ||
@@ -1285,0 +1433,0 @@ exports.writeI56BE = writeI56BE; |
@@ -356,2 +356,32 @@ /*! | ||
/** | ||
* Read uint56le. | ||
* @returns {BigInt} | ||
*/ | ||
readBigU56() { | ||
this.check(7); | ||
const ret = encoding.readBigU56(this.data, this.offset); | ||
this.offset += 7; | ||
return ret; | ||
} | ||
/** | ||
* Read uint56be. | ||
* @returns {BigInt} | ||
*/ | ||
readBigU56BE() { | ||
this.check(7); | ||
const ret = encoding.readBigU56BE(this.data, this.offset); | ||
this.offset += 7; | ||
return ret; | ||
} | ||
/** | ||
* Read uint64le as a js number. | ||
@@ -389,2 +419,32 @@ * @returns {Number} | ||
/** | ||
* Read uint64le as a BigInt. | ||
* @returns {BigInt} | ||
*/ | ||
readBigU64() { | ||
this.check(8); | ||
const ret = encoding.readBigU64(this.data, this.offset); | ||
this.offset += 8; | ||
return ret; | ||
} | ||
/** | ||
* Read uint64be as a BigInt. | ||
* @returns {BigInt} | ||
*/ | ||
readBigU64BE() { | ||
this.check(8); | ||
const ret = encoding.readBigU64BE(this.data, this.offset); | ||
this.offset += 8; | ||
return ret; | ||
} | ||
/** | ||
* Read int8. | ||
@@ -585,2 +645,32 @@ * @returns {Number} | ||
/** | ||
* Read int56le. | ||
* @returns {BigInt} | ||
*/ | ||
readBigI56() { | ||
this.check(7); | ||
const ret = encoding.readBigI56(this.data, this.offset); | ||
this.offset += 7; | ||
return ret; | ||
} | ||
/** | ||
* Read int56be. | ||
* @returns {BigInt} | ||
*/ | ||
readBigI56BE() { | ||
this.check(7); | ||
const ret = encoding.readBigI56BE(this.data, this.offset); | ||
this.offset += 7; | ||
return ret; | ||
} | ||
/** | ||
* Read int64le as a js number. | ||
@@ -618,2 +708,32 @@ * @returns {Number} | ||
/** | ||
* Read int64le as a BigInt. | ||
* @returns {BigInt} | ||
*/ | ||
readBigI64() { | ||
this.check(8); | ||
const ret = encoding.readBigI64(this.data, this.offset); | ||
this.offset += 8; | ||
return ret; | ||
} | ||
/** | ||
* Read int64be as a BigInt. | ||
* @returns {BigInt} | ||
*/ | ||
readBigI64BE() { | ||
this.check(8); | ||
const ret = encoding.readBigI64BE(this.data, this.offset); | ||
this.offset += 8; | ||
return ret; | ||
} | ||
/** | ||
* Read float le. | ||
@@ -620,0 +740,0 @@ * @returns {Number} |
@@ -306,2 +306,24 @@ /*! | ||
/** | ||
* Write uint56le. | ||
* @param {BigInt} value | ||
*/ | ||
writeBigU56(value) { | ||
this.check(7); | ||
this.offset = encoding.writeBigU56(this.data, value, this.offset); | ||
return this; | ||
} | ||
/** | ||
* Write uint56be. | ||
* @param {BigInt} value | ||
*/ | ||
writeBigU56BE(value) { | ||
this.check(7); | ||
this.offset = encoding.writeBigU56BE(this.data, value, this.offset); | ||
return this; | ||
} | ||
/** | ||
* Write uint64le. | ||
@@ -329,2 +351,24 @@ * @param {Number} value | ||
/** | ||
* Write uint64le. | ||
* @param {BigInt} value | ||
*/ | ||
writeBigU64(value) { | ||
this.check(8); | ||
this.offset = encoding.writeBigU64(this.data, value, this.offset); | ||
return this; | ||
} | ||
/** | ||
* Write uint64be. | ||
* @param {BigInt} value | ||
*/ | ||
writeBigU64BE(value) { | ||
this.check(8); | ||
this.offset = encoding.writeBigU64BE(this.data, value, this.offset); | ||
return this; | ||
} | ||
/** | ||
* Write int8. | ||
@@ -473,2 +517,24 @@ * @param {Number} value | ||
/** | ||
* Write int56le. | ||
* @param {BigInt} value | ||
*/ | ||
writeBigI56(value) { | ||
this.check(7); | ||
this.offset = encoding.writeBigI56(this.data, value, this.offset); | ||
return this; | ||
} | ||
/** | ||
* Write int56be. | ||
* @param {BigInt} value | ||
*/ | ||
writeBigI56BE(value) { | ||
this.check(7); | ||
this.offset = encoding.writeBigI56BE(this.data, value, this.offset); | ||
return this; | ||
} | ||
/** | ||
* Write int64le. | ||
@@ -496,2 +562,24 @@ * @param {Number} value | ||
/** | ||
* Write int64le. | ||
* @param {BigInt} value | ||
*/ | ||
writeBigI64(value) { | ||
this.check(8); | ||
this.offset = encoding.writeBigI64(this.data, value, this.offset); | ||
return this; | ||
} | ||
/** | ||
* Write int64be. | ||
* @param {BigInt} value | ||
*/ | ||
writeBigI64BE(value) { | ||
this.check(8); | ||
this.offset = encoding.writeBigI64BE(this.data, value, this.offset); | ||
return this; | ||
} | ||
/** | ||
* Write float le. | ||
@@ -498,0 +586,0 @@ * @param {Number} value |
@@ -59,2 +59,10 @@ /*! | ||
const FILL = 40; | ||
const BIG_U56 = 41; | ||
const BIG_U56BE = 42; | ||
const BIG_U64 = 43; | ||
const BIG_U64BE = 44; | ||
const BIG_I56 = 45; | ||
const BIG_I56BE = 46; | ||
const BIG_I64 = 47; | ||
const BIG_I64BE = 48; | ||
@@ -212,2 +220,26 @@ /** | ||
break; | ||
case BIG_U56: | ||
off = encoding.writeBigU56(data, op.value, off); | ||
break; | ||
case BIG_U56BE: | ||
off = encoding.writeBigU56BE(data, op.value, off); | ||
break; | ||
case BIG_U64: | ||
off = encoding.writeBigU64(data, op.value, off); | ||
break; | ||
case BIG_U64BE: | ||
off = encoding.writeBigU64BE(data, op.value, off); | ||
break; | ||
case BIG_I56: | ||
off = encoding.writeBigI56(data, op.value, off); | ||
break; | ||
case BIG_I56BE: | ||
off = encoding.writeBigI56BE(data, op.value, off); | ||
break; | ||
case BIG_I64: | ||
off = encoding.writeBigI64(data, op.value, off); | ||
break; | ||
case BIG_I64BE: | ||
off = encoding.writeBigI64BE(data, op.value, off); | ||
break; | ||
default: | ||
@@ -406,2 +438,24 @@ throw new Error('Invalid type.'); | ||
/** | ||
* Write uint56le. | ||
* @param {BigInt} value | ||
*/ | ||
writeBigU56(value) { | ||
this.offset += 7; | ||
this.ops.push(new BigOp(BIG_U56, value)); | ||
return this; | ||
} | ||
/** | ||
* Write uint56be. | ||
* @param {BigInt} value | ||
*/ | ||
writeBigU56BE(value) { | ||
this.offset += 7; | ||
this.ops.push(new BigOp(BIG_U56BE, value)); | ||
return this; | ||
} | ||
/** | ||
* Write uint64le. | ||
@@ -429,2 +483,24 @@ * @param {Number} value | ||
/** | ||
* Write uint64le. | ||
* @param {BigInt} value | ||
*/ | ||
writeBigU64(value) { | ||
this.offset += 8; | ||
this.ops.push(new BigOp(BIG_U64, value)); | ||
return this; | ||
} | ||
/** | ||
* Write uint64be. | ||
* @param {BigInt} value | ||
*/ | ||
writeBigU64BE(value) { | ||
this.offset += 8; | ||
this.ops.push(new BigOp(BIG_U64BE, value)); | ||
return this; | ||
} | ||
/** | ||
* Write int8. | ||
@@ -573,2 +649,24 @@ * @param {Number} value | ||
/** | ||
* Write int56le. | ||
* @param {BigInt} value | ||
*/ | ||
writeBigI56(value) { | ||
this.offset += 7; | ||
this.ops.push(new BigOp(BIG_I56, value)); | ||
return this; | ||
} | ||
/** | ||
* Write int56be. | ||
* @param {BigInt} value | ||
*/ | ||
writeBigI56BE(value) { | ||
this.offset += 7; | ||
this.ops.push(new BigOp(BIG_I56BE, value)); | ||
return this; | ||
} | ||
/** | ||
* Write int64le. | ||
@@ -596,2 +694,24 @@ * @param {Number} value | ||
/** | ||
* Write int64le. | ||
* @param {BigInt} value | ||
*/ | ||
writeBigI64(value) { | ||
this.offset += 8; | ||
this.ops.push(new BigOp(BIG_I64, value)); | ||
return this; | ||
} | ||
/** | ||
* Write int64be. | ||
* @param {BigInt} value | ||
*/ | ||
writeBigI64BE(value) { | ||
this.offset += 8; | ||
this.ops.push(new BigOp(BIG_I64BE, value)); | ||
return this; | ||
} | ||
/** | ||
* Write float le. | ||
@@ -856,2 +976,9 @@ * @param {Number} value | ||
class BigOp extends WriteOp { | ||
constructor(type, value) { | ||
super(type); | ||
this.value = value; | ||
} | ||
} | ||
class BufferOp extends WriteOp { | ||
@@ -858,0 +985,0 @@ constructor(type, data) { |
{ | ||
"name": "bufio", | ||
"version": "1.0.7", | ||
"version": "1.1.0", | ||
"description": "Buffer and serialization utilities for javascript", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
97992
3748