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/node.cjs
CHANGED
|
@@ -36,6 +36,16 @@ let defaultOptions = {
|
|
|
36
36
|
mapsAsObjects: true
|
|
37
37
|
};
|
|
38
38
|
let sequentialMode = false;
|
|
39
|
+
let inlineObjectReadThreshold = 2;
|
|
40
|
+
// no-eval build
|
|
41
|
+
try {
|
|
42
|
+
new Function('');
|
|
43
|
+
} catch(error) {
|
|
44
|
+
// if eval variants are not supported, do not create inline object readers ever
|
|
45
|
+
inlineObjectReadThreshold = Infinity;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
|
|
39
49
|
|
|
40
50
|
class Decoder {
|
|
41
51
|
constructor(options) {
|
|
@@ -468,7 +478,7 @@ function createStructureReader(structure) {
|
|
|
468
478
|
return compiledReader(read) // with the right length, so we use it
|
|
469
479
|
compiledReader = compiledReader.next; // see if there is another reader with the right length
|
|
470
480
|
}
|
|
471
|
-
if (this.slowReads++ >=
|
|
481
|
+
if (this.slowReads++ >= inlineObjectReadThreshold) { // create a fast compiled reader
|
|
472
482
|
let array = this.length == length ? this : this.slice(0, length);
|
|
473
483
|
compiledReader = currentDecoder.keyMap
|
|
474
484
|
? new Function('r', 'return {' + array.map(k => currentDecoder.decodeKey(k)).map(k => validName.test(k) ? safeKey(k) + ':r()' : ('[' + JSON.stringify(k) + ']:r()')).join(',') + '}')
|
|
@@ -1135,7 +1145,7 @@ try {
|
|
|
1135
1145
|
textEncoder = new TextEncoder();
|
|
1136
1146
|
} catch (error) {}
|
|
1137
1147
|
let extensions, extensionClasses;
|
|
1138
|
-
const Buffer$1 = globalThis.Buffer;
|
|
1148
|
+
const Buffer$1 = typeof globalThis === 'object' && globalThis.Buffer;
|
|
1139
1149
|
const hasNodeBuffer = typeof Buffer$1 !== 'undefined';
|
|
1140
1150
|
const ByteArrayAllocate = hasNodeBuffer ? Buffer$1.allocUnsafeSlow : Uint8Array;
|
|
1141
1151
|
const ByteArray = hasNodeBuffer ? Buffer$1 : Uint8Array;
|