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/index.js
CHANGED
|
@@ -945,7 +945,7 @@
|
|
|
945
945
|
let length = data.length;
|
|
946
946
|
let value = BigInt(data[0] & 0x80 ? data[0] - 0x100 : data[0]);
|
|
947
947
|
for (let i = 1; i < length; i++) {
|
|
948
|
-
value <<=
|
|
948
|
+
value <<= BigInt(8);
|
|
949
949
|
value += BigInt(data[i]);
|
|
950
950
|
}
|
|
951
951
|
return value;
|
|
@@ -1141,7 +1141,7 @@
|
|
|
1141
1141
|
let structures;
|
|
1142
1142
|
let referenceMap;
|
|
1143
1143
|
let encodeUtf8 = ByteArray.prototype.utf8Write ? function(string, position) {
|
|
1144
|
-
return target.utf8Write(string, position,
|
|
1144
|
+
return target.utf8Write(string, position, target.byteLength - position)
|
|
1145
1145
|
} : (textEncoder && textEncoder.encodeInto) ?
|
|
1146
1146
|
function(string, position) {
|
|
1147
1147
|
return textEncoder.encodeInto(string, target.subarray(position)).written
|
|
@@ -1649,18 +1649,20 @@
|
|
|
1649
1649
|
if (this.largeBigIntToFloat) {
|
|
1650
1650
|
target[position++] = 0xcb;
|
|
1651
1651
|
targetView.setFloat64(position, Number(value));
|
|
1652
|
-
} else if (this.
|
|
1652
|
+
} else if (this.largeBigIntToString) {
|
|
1653
|
+
return pack(value.toString());
|
|
1654
|
+
} else if (this.useBigIntExtension && value < BigInt(2)**BigInt(1023) && value > -(BigInt(2)**BigInt(1023))) {
|
|
1653
1655
|
target[position++] = 0xc7;
|
|
1654
1656
|
position++;
|
|
1655
1657
|
target[position++] = 0x42; // "B" for BigInt
|
|
1656
1658
|
let bytes = [];
|
|
1657
1659
|
let alignedSign;
|
|
1658
1660
|
do {
|
|
1659
|
-
let byte = value &
|
|
1660
|
-
alignedSign = (byte &
|
|
1661
|
+
let byte = value & BigInt(0xff);
|
|
1662
|
+
alignedSign = (byte & BigInt(0x80)) === (value < BigInt(0) ? BigInt(0x80) : BigInt(0));
|
|
1661
1663
|
bytes.push(byte);
|
|
1662
|
-
value >>=
|
|
1663
|
-
} while (!((value ===
|
|
1664
|
+
value >>= BigInt(8);
|
|
1665
|
+
} while (!((value === BigInt(0) || value === BigInt(-1)) && alignedSign));
|
|
1664
1666
|
target[position-2] = bytes.length;
|
|
1665
1667
|
for (let i = bytes.length; i > 0;) {
|
|
1666
1668
|
target[position++] = Number(bytes[--i]);
|
|
@@ -1668,7 +1670,8 @@
|
|
|
1668
1670
|
return
|
|
1669
1671
|
} else {
|
|
1670
1672
|
throw new RangeError(value + ' was too large to fit in MessagePack 64-bit integer format, use' +
|
|
1671
|
-
' useBigIntExtension or set largeBigIntToFloat to convert to float-64'
|
|
1673
|
+
' useBigIntExtension, or set largeBigIntToFloat to convert to float-64, or set' +
|
|
1674
|
+
' largeBigIntToString to convert to string')
|
|
1672
1675
|
}
|
|
1673
1676
|
}
|
|
1674
1677
|
position += 8;
|
|
@@ -1738,6 +1741,10 @@
|
|
|
1738
1741
|
size++;
|
|
1739
1742
|
}
|
|
1740
1743
|
}
|
|
1744
|
+
if (size > 0xffff) {
|
|
1745
|
+
throw new Error('Object is too large to serialize with fast 16-bit map size,' +
|
|
1746
|
+
' use the "variableMapSize" option to serialize this object');
|
|
1747
|
+
}
|
|
1741
1748
|
target[objectOffset++ + start] = size >> 8;
|
|
1742
1749
|
target[objectOffset + start] = size & 0xff;
|
|
1743
1750
|
};
|
|
@@ -2092,7 +2099,7 @@
|
|
|
2092
2099
|
target[position++] = length >> 8;
|
|
2093
2100
|
target[position++] = length & 0xff;
|
|
2094
2101
|
} else {
|
|
2095
|
-
|
|
2102
|
+
let { target, position, targetView } = allocateForWrite(length + 5);
|
|
2096
2103
|
target[position++] = 0xc6;
|
|
2097
2104
|
targetView.setUint32(position, length);
|
|
2098
2105
|
position += 4;
|