msgpackr 1.11.0 → 1.11.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -1
- package/dist/index-no-eval.cjs +16 -9
- package/dist/index-no-eval.cjs.map +1 -1
- package/dist/index-no-eval.min.js +1 -1
- package/dist/index-no-eval.min.js.map +1 -1
- package/dist/index.js +16 -9
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +1 -1
- package/dist/node.cjs +17 -10
- package/dist/node.cjs.map +1 -1
- package/dist/test.js +24 -10
- package/dist/test.js.map +1 -1
- package/dist/unpack-no-eval.cjs +1 -1
- package/dist/unpack-no-eval.cjs.map +1 -1
- package/index.d.cts +1 -0
- package/index.d.ts +1 -0
- package/pack.js +16 -9
- package/package.json +1 -1
- package/struct.js +1 -1
- package/unpack.js +1 -1
package/dist/node.cjs
CHANGED
|
@@ -1001,7 +1001,7 @@ currentExtensions[0x42] = (data) => {
|
|
|
1001
1001
|
let length = data.length;
|
|
1002
1002
|
let value = BigInt(data[0] & 0x80 ? data[0] - 0x100 : data[0]);
|
|
1003
1003
|
for (let i = 1; i < length; i++) {
|
|
1004
|
-
value <<=
|
|
1004
|
+
value <<= BigInt(8);
|
|
1005
1005
|
value += BigInt(data[i]);
|
|
1006
1006
|
}
|
|
1007
1007
|
return value;
|
|
@@ -1208,7 +1208,7 @@ class Packr extends Unpackr {
|
|
|
1208
1208
|
let structures;
|
|
1209
1209
|
let referenceMap;
|
|
1210
1210
|
let encodeUtf8 = ByteArray.prototype.utf8Write ? function(string, position) {
|
|
1211
|
-
return target.utf8Write(string, position,
|
|
1211
|
+
return target.utf8Write(string, position, target.byteLength - position)
|
|
1212
1212
|
} : (textEncoder$1 && textEncoder$1.encodeInto) ?
|
|
1213
1213
|
function(string, position) {
|
|
1214
1214
|
return textEncoder$1.encodeInto(string, target.subarray(position)).written
|
|
@@ -1716,18 +1716,20 @@ class Packr extends Unpackr {
|
|
|
1716
1716
|
if (this.largeBigIntToFloat) {
|
|
1717
1717
|
target[position++] = 0xcb;
|
|
1718
1718
|
targetView.setFloat64(position, Number(value));
|
|
1719
|
-
} else if (this.
|
|
1719
|
+
} else if (this.largeBigIntToString) {
|
|
1720
|
+
return pack(value.toString());
|
|
1721
|
+
} else if (this.useBigIntExtension && value < BigInt(2)**BigInt(1023) && value > -(BigInt(2)**BigInt(1023))) {
|
|
1720
1722
|
target[position++] = 0xc7;
|
|
1721
1723
|
position++;
|
|
1722
1724
|
target[position++] = 0x42; // "B" for BigInt
|
|
1723
1725
|
let bytes = [];
|
|
1724
1726
|
let alignedSign;
|
|
1725
1727
|
do {
|
|
1726
|
-
let byte = value &
|
|
1727
|
-
alignedSign = (byte &
|
|
1728
|
+
let byte = value & BigInt(0xff);
|
|
1729
|
+
alignedSign = (byte & BigInt(0x80)) === (value < BigInt(0) ? BigInt(0x80) : BigInt(0));
|
|
1728
1730
|
bytes.push(byte);
|
|
1729
|
-
value >>=
|
|
1730
|
-
} while (!((value ===
|
|
1731
|
+
value >>= BigInt(8);
|
|
1732
|
+
} while (!((value === BigInt(0) || value === BigInt(-1)) && alignedSign));
|
|
1731
1733
|
target[position-2] = bytes.length;
|
|
1732
1734
|
for (let i = bytes.length; i > 0;) {
|
|
1733
1735
|
target[position++] = Number(bytes[--i]);
|
|
@@ -1735,7 +1737,8 @@ class Packr extends Unpackr {
|
|
|
1735
1737
|
return
|
|
1736
1738
|
} else {
|
|
1737
1739
|
throw new RangeError(value + ' was too large to fit in MessagePack 64-bit integer format, use' +
|
|
1738
|
-
' useBigIntExtension or set largeBigIntToFloat to convert to float-64'
|
|
1740
|
+
' useBigIntExtension, or set largeBigIntToFloat to convert to float-64, or set' +
|
|
1741
|
+
' largeBigIntToString to convert to string')
|
|
1739
1742
|
}
|
|
1740
1743
|
}
|
|
1741
1744
|
position += 8;
|
|
@@ -1805,6 +1808,10 @@ class Packr extends Unpackr {
|
|
|
1805
1808
|
size++;
|
|
1806
1809
|
}
|
|
1807
1810
|
}
|
|
1811
|
+
if (size > 0xffff) {
|
|
1812
|
+
throw new Error('Object is too large to serialize with fast 16-bit map size,' +
|
|
1813
|
+
' use the "variableMapSize" option to serialize this object');
|
|
1814
|
+
}
|
|
1808
1815
|
target[objectOffset++ + start] = size >> 8;
|
|
1809
1816
|
target[objectOffset + start] = size & 0xff;
|
|
1810
1817
|
};
|
|
@@ -2159,7 +2166,7 @@ function writeBuffer(buffer, allocateForWrite) {
|
|
|
2159
2166
|
target[position++] = length >> 8;
|
|
2160
2167
|
target[position++] = length & 0xff;
|
|
2161
2168
|
} else {
|
|
2162
|
-
|
|
2169
|
+
let { target, position, targetView } = allocateForWrite(length + 5);
|
|
2163
2170
|
target[position++] = 0xc6;
|
|
2164
2171
|
targetView.setUint32(position, length);
|
|
2165
2172
|
position += 4;
|
|
@@ -2297,7 +2304,7 @@ try {
|
|
|
2297
2304
|
textEncoder = new TextEncoder();
|
|
2298
2305
|
} catch (error) {}
|
|
2299
2306
|
const encodeUtf8 = hasNodeBuffer ? function(target, string, position) {
|
|
2300
|
-
return target.utf8Write(string, position,
|
|
2307
|
+
return target.utf8Write(string, position, target.byteLength - position)
|
|
2301
2308
|
} : (textEncoder && textEncoder.encodeInto) ?
|
|
2302
2309
|
function(target, string, position) {
|
|
2303
2310
|
return textEncoder.encodeInto(string, target.subarray(position)).written
|