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/index-no-eval.cjs
CHANGED
|
@@ -944,47 +944,21 @@
|
|
|
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] = data => {
|
|
948
|
-
|
|
949
|
-
let
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
947
|
+
currentExtensions[0x42] = (data) => {
|
|
948
|
+
// decode bigint
|
|
949
|
+
let length = data.length;
|
|
950
|
+
let value = BigInt(data[0] & 0x80 ? data[0] - 0x100 : data[0]);
|
|
951
|
+
for (let i = 1; i < length; i++) {
|
|
952
|
+
value <<= BigInt(8);
|
|
953
|
+
value += BigInt(data[i]);
|
|
953
954
|
}
|
|
954
|
-
|
|
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
|
|
955
|
+
return value;
|
|
975
956
|
};
|
|
976
957
|
|
|
977
|
-
let errors = {
|
|
978
|
-
Error, EvalError, RangeError, ReferenceError, SyntaxError, TypeError, URIError, AggregateError: typeof AggregateError === 'function' ? AggregateError : null,
|
|
979
|
-
};
|
|
958
|
+
let errors = { Error, TypeError, ReferenceError };
|
|
980
959
|
currentExtensions[0x65] = () => {
|
|
981
960
|
let data = read();
|
|
982
|
-
|
|
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] })
|
|
961
|
+
return (errors[data[0]] || Error)(data[1], { cause: data[2] })
|
|
988
962
|
};
|
|
989
963
|
|
|
990
964
|
currentExtensions[0x69] = (data) => {
|
|
@@ -1692,46 +1666,22 @@
|
|
|
1692
1666
|
targetView.setFloat64(position, Number(value));
|
|
1693
1667
|
} else if (this.largeBigIntToString) {
|
|
1694
1668
|
return pack(value.toString());
|
|
1695
|
-
} else if (this.useBigIntExtension || this.moreTypes) {
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
let invert = value < 0;
|
|
1711
|
-
let string = (invert ? ~value : value).toString(16);
|
|
1712
|
-
if (string.length % 2) {
|
|
1713
|
-
string = '0' + string;
|
|
1714
|
-
} else if (parseInt(string.charAt(0), 16) >= 8) {
|
|
1715
|
-
string = '00' + string;
|
|
1716
|
-
}
|
|
1717
|
-
|
|
1718
|
-
if (hasNodeBuffer) {
|
|
1719
|
-
array = Buffer.from(string, 'hex');
|
|
1720
|
-
} else {
|
|
1721
|
-
array = new Uint8Array(string.length / 2);
|
|
1722
|
-
for (let i = 0; i < array.length; i++) {
|
|
1723
|
-
array[i] = parseInt(string.slice(i * 2, i * 2 + 2), 16);
|
|
1724
|
-
}
|
|
1725
|
-
}
|
|
1726
|
-
|
|
1727
|
-
if (invert) {
|
|
1728
|
-
for (let i = 0; i < array.length; i++) array[i] = ~array[i];
|
|
1729
|
-
}
|
|
1669
|
+
} else if ((this.useBigIntExtension || this.moreTypes) && value < BigInt(2)**BigInt(1023) && value > -(BigInt(2)**BigInt(1023))) {
|
|
1670
|
+
target[position++] = 0xc7;
|
|
1671
|
+
position++;
|
|
1672
|
+
target[position++] = 0x42; // "B" for BigInt
|
|
1673
|
+
let bytes = [];
|
|
1674
|
+
let alignedSign;
|
|
1675
|
+
do {
|
|
1676
|
+
let byte = value & BigInt(0xff);
|
|
1677
|
+
alignedSign = (byte & BigInt(0x80)) === (value < BigInt(0) ? BigInt(0x80) : BigInt(0));
|
|
1678
|
+
bytes.push(byte);
|
|
1679
|
+
value >>= BigInt(8);
|
|
1680
|
+
} while (!((value === BigInt(0) || value === BigInt(-1)) && alignedSign));
|
|
1681
|
+
target[position-2] = bytes.length;
|
|
1682
|
+
for (let i = bytes.length; i > 0;) {
|
|
1683
|
+
target[position++] = Number(bytes[--i]);
|
|
1730
1684
|
}
|
|
1731
|
-
|
|
1732
|
-
if (array.length + position > safeEnd)
|
|
1733
|
-
makeRoom(array.length + position);
|
|
1734
|
-
position = writeExtensionData(array, target, position, 0x42);
|
|
1735
1685
|
return
|
|
1736
1686
|
} else {
|
|
1737
1687
|
throw new RangeError(value + ' was too large to fit in MessagePack 64-bit integer format, use' +
|