cbor-x 1.5.2 → 1.5.3
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/decode.js +12 -1
- package/dist/decode-no-eval.cjs +12 -1
- package/dist/decode-no-eval.cjs.map +1 -1
- package/dist/index-no-eval.cjs +13 -2
- 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 +12 -2
- 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 +12 -2
- package/dist/node.cjs.map +1 -1
- package/encode.js +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -34,6 +34,16 @@
|
|
|
34
34
|
mapsAsObjects: true
|
|
35
35
|
};
|
|
36
36
|
let sequentialMode = false;
|
|
37
|
+
let inlineObjectReadThreshold = 2;
|
|
38
|
+
// no-eval build
|
|
39
|
+
try {
|
|
40
|
+
new Function('');
|
|
41
|
+
} catch(error) {
|
|
42
|
+
// if eval variants are not supported, do not create inline object readers ever
|
|
43
|
+
inlineObjectReadThreshold = Infinity;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
|
|
37
47
|
|
|
38
48
|
class Decoder {
|
|
39
49
|
constructor(options) {
|
|
@@ -464,7 +474,7 @@
|
|
|
464
474
|
return compiledReader(read) // with the right length, so we use it
|
|
465
475
|
compiledReader = compiledReader.next; // see if there is another reader with the right length
|
|
466
476
|
}
|
|
467
|
-
if (this.slowReads++ >=
|
|
477
|
+
if (this.slowReads++ >= inlineObjectReadThreshold) { // create a fast compiled reader
|
|
468
478
|
let array = this.length == length ? this : this.slice(0, length);
|
|
469
479
|
compiledReader = currentDecoder.keyMap
|
|
470
480
|
? new Function('r', 'return {' + array.map(k => currentDecoder.decodeKey(k)).map(k => validName.test(k) ? safeKey(k) + ':r()' : ('[' + JSON.stringify(k) + ']:r()')).join(',') + '}')
|
|
@@ -1092,7 +1102,7 @@
|
|
|
1092
1102
|
textEncoder = new TextEncoder();
|
|
1093
1103
|
} catch (error) {}
|
|
1094
1104
|
let extensions, extensionClasses;
|
|
1095
|
-
const Buffer$1 = globalThis.Buffer;
|
|
1105
|
+
const Buffer$1 = typeof globalThis === 'object' && globalThis.Buffer;
|
|
1096
1106
|
const hasNodeBuffer = typeof Buffer$1 !== 'undefined';
|
|
1097
1107
|
const ByteArrayAllocate = hasNodeBuffer ? Buffer$1.allocUnsafeSlow : Uint8Array;
|
|
1098
1108
|
const ByteArray = hasNodeBuffer ? Buffer$1 : Uint8Array;
|