msgpackr 1.11.3 → 1.11.4
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 +25 -75
- 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 +25 -75
- 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 +26 -76
- package/dist/node.cjs.map +1 -1
- package/dist/test.js +35 -104
- package/dist/test.js.map +1 -1
- package/dist/unpack-no-eval.cjs +10 -36
- package/dist/unpack-no-eval.cjs.map +1 -1
- package/pack.js +16 -40
- package/package.json +1 -1
- package/unpack.js +10 -36
package/dist/node.cjs
CHANGED
|
@@ -999,47 +999,21 @@ const recordDefinition = (id, highByte) => {
|
|
|
999
999
|
currentExtensions[0] = () => {}; // notepack defines extension 0 to mean undefined, so use that as the default here
|
|
1000
1000
|
currentExtensions[0].noBuffer = true;
|
|
1001
1001
|
|
|
1002
|
-
currentExtensions[0x42] = data => {
|
|
1003
|
-
|
|
1004
|
-
let
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
let decode = (start, end) => {
|
|
1012
|
-
let length = end - start;
|
|
1013
|
-
if (length <= 40) {
|
|
1014
|
-
let out = view.getBigUint64(start);
|
|
1015
|
-
for (let i = start + 8; i < end; i += 8) {
|
|
1016
|
-
out <<= BigInt(64n);
|
|
1017
|
-
out |= view.getBigUint64(i);
|
|
1018
|
-
}
|
|
1019
|
-
return out
|
|
1020
|
-
}
|
|
1021
|
-
// if (length === 8) return view.getBigUint64(start)
|
|
1022
|
-
let middle = start + (length >> 4 << 3);
|
|
1023
|
-
let left = decode(start, middle);
|
|
1024
|
-
let right = decode(middle, end);
|
|
1025
|
-
return (left << BigInt((end - middle) * 8)) | right
|
|
1026
|
-
};
|
|
1027
|
-
head = (head << BigInt((view.byteLength - headLength) * 8)) | decode(headLength, view.byteLength);
|
|
1028
|
-
}
|
|
1029
|
-
return head
|
|
1002
|
+
currentExtensions[0x42] = (data) => {
|
|
1003
|
+
// decode bigint
|
|
1004
|
+
let length = data.length;
|
|
1005
|
+
let value = BigInt(data[0] & 0x80 ? data[0] - 0x100 : data[0]);
|
|
1006
|
+
for (let i = 1; i < length; i++) {
|
|
1007
|
+
value <<= BigInt(8);
|
|
1008
|
+
value += BigInt(data[i]);
|
|
1009
|
+
}
|
|
1010
|
+
return value;
|
|
1030
1011
|
};
|
|
1031
1012
|
|
|
1032
|
-
let errors = {
|
|
1033
|
-
Error, EvalError, RangeError, ReferenceError, SyntaxError, TypeError, URIError, AggregateError: typeof AggregateError === 'function' ? AggregateError : null,
|
|
1034
|
-
};
|
|
1013
|
+
let errors = { Error, TypeError, ReferenceError };
|
|
1035
1014
|
currentExtensions[0x65] = () => {
|
|
1036
1015
|
let data = read();
|
|
1037
|
-
|
|
1038
|
-
let error = Error(data[1], { cause: data[2] });
|
|
1039
|
-
error.name = data[0];
|
|
1040
|
-
return error
|
|
1041
|
-
}
|
|
1042
|
-
return errors[data[0]](data[1], { cause: data[2] })
|
|
1016
|
+
return (errors[data[0]] || Error)(data[1], { cause: data[2] })
|
|
1043
1017
|
};
|
|
1044
1018
|
|
|
1045
1019
|
currentExtensions[0x69] = (data) => {
|
|
@@ -1758,46 +1732,22 @@ class Packr extends Unpackr {
|
|
|
1758
1732
|
targetView.setFloat64(position, Number(value));
|
|
1759
1733
|
} else if (this.largeBigIntToString) {
|
|
1760
1734
|
return pack(value.toString());
|
|
1761
|
-
} else if (this.useBigIntExtension || this.moreTypes) {
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
let invert = value < 0;
|
|
1777
|
-
let string = (invert ? ~value : value).toString(16);
|
|
1778
|
-
if (string.length % 2) {
|
|
1779
|
-
string = '0' + string;
|
|
1780
|
-
} else if (parseInt(string.charAt(0), 16) >= 8) {
|
|
1781
|
-
string = '00' + string;
|
|
1782
|
-
}
|
|
1783
|
-
|
|
1784
|
-
if (hasNodeBuffer$1) {
|
|
1785
|
-
array = Buffer.from(string, 'hex');
|
|
1786
|
-
} else {
|
|
1787
|
-
array = new Uint8Array(string.length / 2);
|
|
1788
|
-
for (let i = 0; i < array.length; i++) {
|
|
1789
|
-
array[i] = parseInt(string.slice(i * 2, i * 2 + 2), 16);
|
|
1790
|
-
}
|
|
1791
|
-
}
|
|
1792
|
-
|
|
1793
|
-
if (invert) {
|
|
1794
|
-
for (let i = 0; i < array.length; i++) array[i] = ~array[i];
|
|
1795
|
-
}
|
|
1735
|
+
} else if ((this.useBigIntExtension || this.moreTypes) && value < BigInt(2)**BigInt(1023) && value > -(BigInt(2)**BigInt(1023))) {
|
|
1736
|
+
target[position++] = 0xc7;
|
|
1737
|
+
position++;
|
|
1738
|
+
target[position++] = 0x42; // "B" for BigInt
|
|
1739
|
+
let bytes = [];
|
|
1740
|
+
let alignedSign;
|
|
1741
|
+
do {
|
|
1742
|
+
let byte = value & BigInt(0xff);
|
|
1743
|
+
alignedSign = (byte & BigInt(0x80)) === (value < BigInt(0) ? BigInt(0x80) : BigInt(0));
|
|
1744
|
+
bytes.push(byte);
|
|
1745
|
+
value >>= BigInt(8);
|
|
1746
|
+
} while (!((value === BigInt(0) || value === BigInt(-1)) && alignedSign));
|
|
1747
|
+
target[position-2] = bytes.length;
|
|
1748
|
+
for (let i = bytes.length; i > 0;) {
|
|
1749
|
+
target[position++] = Number(bytes[--i]);
|
|
1796
1750
|
}
|
|
1797
|
-
|
|
1798
|
-
if (array.length + position > safeEnd)
|
|
1799
|
-
makeRoom(array.length + position);
|
|
1800
|
-
position = writeExtensionData(array, target, position, 0x42);
|
|
1801
1751
|
return
|
|
1802
1752
|
} else {
|
|
1803
1753
|
throw new RangeError(value + ' was too large to fit in MessagePack 64-bit integer format, use' +
|