msgpackr 1.11.9 → 1.11.11
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 +1 -3
- package/benchmark.md +26 -16
- package/dist/index-no-eval.cjs +11 -11
- 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 +11 -11
- 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 +11 -11
- package/dist/node.cjs.map +1 -1
- package/dist/test.js +11 -11
- package/dist/test.js.map +1 -1
- package/dist/unpack-no-eval.cjs +11 -11
- package/dist/unpack-no-eval.cjs.map +1 -1
- package/index.d.cts +2 -2
- package/index.d.ts +2 -2
- package/package.json +1 -1
- package/unpack.js +11 -11
package/dist/node.cjs
CHANGED
|
@@ -32,13 +32,6 @@ C1.name = 'MessagePack 0xC1';
|
|
|
32
32
|
var sequentialMode = false;
|
|
33
33
|
var inlineObjectReadThreshold = 2;
|
|
34
34
|
var readStruct$1, onLoadedStructures$1, onSaveState;
|
|
35
|
-
// no-eval build
|
|
36
|
-
try {
|
|
37
|
-
new Function('');
|
|
38
|
-
} catch(error) {
|
|
39
|
-
// if eval variants are not supported, do not create inline object readers ever
|
|
40
|
-
inlineObjectReadThreshold = Infinity;
|
|
41
|
-
}
|
|
42
35
|
|
|
43
36
|
class Unpackr {
|
|
44
37
|
constructor(options) {
|
|
@@ -508,11 +501,18 @@ function createStructureReader(structure, firstId) {
|
|
|
508
501
|
function readObject() {
|
|
509
502
|
// This initial function is quick to instantiate, but runs slower. After several iterations pay the cost to build the faster function
|
|
510
503
|
if (readObject.count++ > inlineObjectReadThreshold) {
|
|
511
|
-
let
|
|
512
|
-
|
|
504
|
+
let optimizedReadObject;
|
|
505
|
+
try {
|
|
506
|
+
optimizedReadObject = structure.read = (new Function('r', 'return function(){return ' + (currentUnpackr.freezeData ? 'Object.freeze' : '') +
|
|
507
|
+
'({' + structure.map(key => key === '__proto__' ? '__proto_:r()' : validName.test(key) ? key + ':r()' : ('[' + JSON.stringify(key) + ']:r()')).join(',') + '})}'))(read);
|
|
508
|
+
} catch(error) {
|
|
509
|
+
// in CF workers, the new Function call could begin to fail at any point in time
|
|
510
|
+
inlineObjectReadThreshold = Infinity; // disable going forward
|
|
511
|
+
return readObject(); // recursively try again
|
|
512
|
+
}
|
|
513
513
|
if (structure.highByte === 0)
|
|
514
514
|
structure.read = createSecondByteReader(firstId, structure.read);
|
|
515
|
-
return
|
|
515
|
+
return optimizedReadObject() // second byte is already read, if there is one so immediately read object
|
|
516
516
|
}
|
|
517
517
|
let object = {};
|
|
518
518
|
for (let i = 0, l = structure.length; i < l; i++) {
|
|
@@ -1032,7 +1032,7 @@ currentExtensions[0x42] = data => {
|
|
|
1032
1032
|
if (length <= 40) {
|
|
1033
1033
|
let out = view.getBigUint64(start);
|
|
1034
1034
|
for (let i = start + 8; i < end; i += 8) {
|
|
1035
|
-
out <<= BigInt(
|
|
1035
|
+
out <<= BigInt(64);
|
|
1036
1036
|
out |= view.getBigUint64(i);
|
|
1037
1037
|
}
|
|
1038
1038
|
return out
|