msgpackr 1.11.4 → 1.11.5
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/dist/index-no-eval.cjs +77 -25
- 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 +77 -25
- 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 +79 -27
- package/dist/node.cjs.map +1 -1
- package/dist/test.js +115 -37
- package/dist/test.js.map +1 -1
- package/dist/unpack-no-eval.cjs +36 -10
- package/dist/unpack-no-eval.cjs.map +1 -1
- package/pack.js +42 -16
- package/package.json +1 -1
- package/struct.js +1 -1
- package/unpack.js +36 -10
package/dist/index-no-eval.cjs
CHANGED
|
@@ -944,21 +944,47 @@
|
|
|
944
944
|
currentExtensions[0] = () => {}; // notepack defines extension 0 to mean undefined, so use that as the default here
|
|
945
945
|
currentExtensions[0].noBuffer = true;
|
|
946
946
|
|
|
947
|
-
currentExtensions[0x42] =
|
|
948
|
-
|
|
949
|
-
let
|
|
950
|
-
let
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
value += BigInt(data[i]);
|
|
947
|
+
currentExtensions[0x42] = data => {
|
|
948
|
+
let headLength = (data.byteLength % 8) || 8;
|
|
949
|
+
let head = BigInt(data[0] & 0x80 ? data[0] - 0x100 : data[0]);
|
|
950
|
+
for (let i = 1; i < headLength; i++) {
|
|
951
|
+
head <<= BigInt(8);
|
|
952
|
+
head += BigInt(data[i]);
|
|
954
953
|
}
|
|
955
|
-
|
|
954
|
+
if (data.byteLength !== headLength) {
|
|
955
|
+
let view = new DataView(data.buffer, data.byteOffset, data.byteLength);
|
|
956
|
+
let decode = (start, end) => {
|
|
957
|
+
let length = end - start;
|
|
958
|
+
if (length <= 40) {
|
|
959
|
+
let out = view.getBigUint64(start);
|
|
960
|
+
for (let i = start + 8; i < end; i += 8) {
|
|
961
|
+
out <<= BigInt(64n);
|
|
962
|
+
out |= view.getBigUint64(i);
|
|
963
|
+
}
|
|
964
|
+
return out
|
|
965
|
+
}
|
|
966
|
+
// if (length === 8) return view.getBigUint64(start)
|
|
967
|
+
let middle = start + (length >> 4 << 3);
|
|
968
|
+
let left = decode(start, middle);
|
|
969
|
+
let right = decode(middle, end);
|
|
970
|
+
return (left << BigInt((end - middle) * 8)) | right
|
|
971
|
+
};
|
|
972
|
+
head = (head << BigInt((view.byteLength - headLength) * 8)) | decode(headLength, view.byteLength);
|
|
973
|
+
}
|
|
974
|
+
return head
|
|
956
975
|
};
|
|
957
976
|
|
|
958
|
-
let errors = {
|
|
977
|
+
let errors = {
|
|
978
|
+
Error, EvalError, RangeError, ReferenceError, SyntaxError, TypeError, URIError, AggregateError: typeof AggregateError === 'function' ? AggregateError : null,
|
|
979
|
+
};
|
|
959
980
|
currentExtensions[0x65] = () => {
|
|
960
981
|
let data = read();
|
|
961
|
-
|
|
982
|
+
if (!errors[data[0]]) {
|
|
983
|
+
let error = Error(data[1], { cause: data[2] });
|
|
984
|
+
error.name = data[0];
|
|
985
|
+
return error
|
|
986
|
+
}
|
|
987
|
+
return errors[data[0]](data[1], { cause: data[2] })
|
|
962
988
|
};
|
|
963
989
|
|
|
964
990
|
currentExtensions[0x69] = (data) => {
|
|
@@ -1666,22 +1692,47 @@
|
|
|
1666
1692
|
targetView.setFloat64(position, Number(value));
|
|
1667
1693
|
} else if (this.largeBigIntToString) {
|
|
1668
1694
|
return pack(value.toString());
|
|
1669
|
-
} else if (
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1695
|
+
} else if (this.useBigIntExtension || this.moreTypes) {
|
|
1696
|
+
let empty = value < 0 ? BigInt(-1) : BigInt(0);
|
|
1697
|
+
|
|
1698
|
+
let array;
|
|
1699
|
+
if (value >> BigInt(0x10000) === empty) {
|
|
1700
|
+
let mask = BigInt(0x10000000000000000) - BigInt(1); // literal would overflow
|
|
1701
|
+
let chunks = [];
|
|
1702
|
+
while (true) {
|
|
1703
|
+
chunks.push(value & mask);
|
|
1704
|
+
if ((value >> BigInt(63)) === empty) break
|
|
1705
|
+
value >>= BigInt(64);
|
|
1706
|
+
}
|
|
1707
|
+
|
|
1708
|
+
array = new Uint8Array(new BigUint64Array(chunks).buffer);
|
|
1709
|
+
array.reverse();
|
|
1710
|
+
} else {
|
|
1711
|
+
let invert = value < 0;
|
|
1712
|
+
let string = (invert ? ~value : value).toString(16);
|
|
1713
|
+
if (string.length % 2) {
|
|
1714
|
+
string = '0' + string;
|
|
1715
|
+
} else if (parseInt(string.charAt(0), 16) >= 8) {
|
|
1716
|
+
string = '00' + string;
|
|
1717
|
+
}
|
|
1718
|
+
|
|
1719
|
+
if (hasNodeBuffer) {
|
|
1720
|
+
array = Buffer.from(string, 'hex');
|
|
1721
|
+
} else {
|
|
1722
|
+
array = new Uint8Array(string.length / 2);
|
|
1723
|
+
for (let i = 0; i < array.length; i++) {
|
|
1724
|
+
array[i] = parseInt(string.slice(i * 2, i * 2 + 2), 16);
|
|
1725
|
+
}
|
|
1726
|
+
}
|
|
1727
|
+
|
|
1728
|
+
if (invert) {
|
|
1729
|
+
for (let i = 0; i < array.length; i++) array[i] = ~array[i];
|
|
1730
|
+
}
|
|
1684
1731
|
}
|
|
1732
|
+
|
|
1733
|
+
if (array.length + position > safeEnd)
|
|
1734
|
+
makeRoom(array.length + position);
|
|
1735
|
+
position = writeExtensionData(array, target, position, 0x42);
|
|
1685
1736
|
return
|
|
1686
1737
|
} else {
|
|
1687
1738
|
throw new RangeError(value + ' was too large to fit in MessagePack 64-bit integer format, use' +
|
|
@@ -1969,6 +2020,7 @@
|
|
|
1969
2020
|
// this means we are finished using our own buffer and we can write over it safely
|
|
1970
2021
|
target = buffer;
|
|
1971
2022
|
target.dataView || (target.dataView = new DataView(target.buffer, target.byteOffset, target.byteLength));
|
|
2023
|
+
targetView = target.dataView;
|
|
1972
2024
|
position = 0;
|
|
1973
2025
|
}
|
|
1974
2026
|
set position (value) {
|