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/test.js
CHANGED
|
@@ -30,13 +30,6 @@
|
|
|
30
30
|
var sequentialMode = false;
|
|
31
31
|
var inlineObjectReadThreshold = 2;
|
|
32
32
|
var readStruct$1, onLoadedStructures$1, onSaveState;
|
|
33
|
-
// no-eval build
|
|
34
|
-
try {
|
|
35
|
-
new Function('');
|
|
36
|
-
} catch(error) {
|
|
37
|
-
// if eval variants are not supported, do not create inline object readers ever
|
|
38
|
-
inlineObjectReadThreshold = Infinity;
|
|
39
|
-
}
|
|
40
33
|
|
|
41
34
|
let Unpackr$1 = class Unpackr {
|
|
42
35
|
constructor(options) {
|
|
@@ -506,11 +499,18 @@
|
|
|
506
499
|
function readObject() {
|
|
507
500
|
// This initial function is quick to instantiate, but runs slower. After several iterations pay the cost to build the faster function
|
|
508
501
|
if (readObject.count++ > inlineObjectReadThreshold) {
|
|
509
|
-
let
|
|
510
|
-
|
|
502
|
+
let optimizedReadObject;
|
|
503
|
+
try {
|
|
504
|
+
optimizedReadObject = structure.read = (new Function('r', 'return function(){return ' + (currentUnpackr.freezeData ? 'Object.freeze' : '') +
|
|
505
|
+
'({' + structure.map(key => key === '__proto__' ? '__proto_:r()' : validName.test(key) ? key + ':r()' : ('[' + JSON.stringify(key) + ']:r()')).join(',') + '})}'))(read);
|
|
506
|
+
} catch(error) {
|
|
507
|
+
// in CF workers, the new Function call could begin to fail at any point in time
|
|
508
|
+
inlineObjectReadThreshold = Infinity; // disable going forward
|
|
509
|
+
return readObject(); // recursively try again
|
|
510
|
+
}
|
|
511
511
|
if (structure.highByte === 0)
|
|
512
512
|
structure.read = createSecondByteReader(firstId, structure.read);
|
|
513
|
-
return
|
|
513
|
+
return optimizedReadObject() // second byte is already read, if there is one so immediately read object
|
|
514
514
|
}
|
|
515
515
|
let object = {};
|
|
516
516
|
for (let i = 0, l = structure.length; i < l; i++) {
|
|
@@ -1028,7 +1028,7 @@
|
|
|
1028
1028
|
if (length <= 40) {
|
|
1029
1029
|
let out = view.getBigUint64(start);
|
|
1030
1030
|
for (let i = start + 8; i < end; i += 8) {
|
|
1031
|
-
out <<= BigInt(
|
|
1031
|
+
out <<= BigInt(64);
|
|
1032
1032
|
out |= view.getBigUint64(i);
|
|
1033
1033
|
}
|
|
1034
1034
|
return out
|