msgpackr 1.8.1 → 1.8.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/README.md +2 -2
- package/dist/index-no-eval.cjs +7 -8
- 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 +7 -8
- 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 +23 -12
- package/dist/node.cjs.map +1 -1
- package/dist/test.js +23 -12
- package/dist/test.js.map +1 -1
- package/dist/unpack-no-eval.cjs +3 -2
- package/dist/unpack-no-eval.cjs.map +1 -1
- package/index.d.cts +73 -0
- package/pack.js +6 -7
- package/package.json +4 -3
- package/struct.js +15 -4
- package/unpack.js +3 -2
package/dist/test.js
CHANGED
|
@@ -118,7 +118,7 @@
|
|
|
118
118
|
let size = source.length;
|
|
119
119
|
let value = this ? this.unpack(source, size) : defaultUnpackr.unpack(source, size);
|
|
120
120
|
if (forEach) {
|
|
121
|
-
forEach(value);
|
|
121
|
+
if (forEach(value) === false) return;
|
|
122
122
|
while(position$1 < size) {
|
|
123
123
|
lastPosition = position$1;
|
|
124
124
|
if (forEach(checkedRead()) === false) {
|
|
@@ -553,7 +553,8 @@
|
|
|
553
553
|
if (string == null) {
|
|
554
554
|
if (bundledStrings$1)
|
|
555
555
|
return readStringJS(length)
|
|
556
|
-
let
|
|
556
|
+
let byteOffset = src.byteOffset;
|
|
557
|
+
let extraction = extractStrings(position$1 - headerLength + byteOffset, srcEnd + byteOffset, src.buffer);
|
|
557
558
|
if (typeof extraction == 'string') {
|
|
558
559
|
string = extraction;
|
|
559
560
|
strings = EMPTY_ARRAY;
|
|
@@ -1168,7 +1169,7 @@
|
|
|
1168
1169
|
if (maxSharedStructures > 8160)
|
|
1169
1170
|
throw new Error('Maximum maxSharedStructure is 8160')
|
|
1170
1171
|
if (options.structuredClone && options.moreTypes == undefined) {
|
|
1171
|
-
|
|
1172
|
+
this.moreTypes = true;
|
|
1172
1173
|
}
|
|
1173
1174
|
let maxOwnStructures = options.maxOwnStructures;
|
|
1174
1175
|
if (maxOwnStructures == null)
|
|
@@ -1863,12 +1864,11 @@
|
|
|
1863
1864
|
if (notifySharedUpdate)
|
|
1864
1865
|
return hasSharedUpdate = true;
|
|
1865
1866
|
position = newPosition;
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
}
|
|
1871
|
-
pack(value);
|
|
1867
|
+
let startTarget = target;
|
|
1868
|
+
pack(value);
|
|
1869
|
+
if (startTarget !== target) {
|
|
1870
|
+
return { position, targetView, target }; // indicate the buffer was re-allocated
|
|
1871
|
+
}
|
|
1872
1872
|
return position;
|
|
1873
1873
|
}, this);
|
|
1874
1874
|
if (newPosition === 0) // bail and go to a msgpack object
|
|
@@ -2786,24 +2786,35 @@
|
|
|
2786
2786
|
let objectLiteralProperties = [];
|
|
2787
2787
|
let args = [];
|
|
2788
2788
|
let i = 0;
|
|
2789
|
+
let hasInheritedProperties;
|
|
2789
2790
|
for (let property of properties) { // assign in enumeration order
|
|
2791
|
+
if (unpackr.alwaysLazyProperty && unpackr.alwaysLazyProperty(property.key)) {
|
|
2792
|
+
// these properties are not eagerly evaluated and this can be used for creating properties
|
|
2793
|
+
// that are not serialized as JSON
|
|
2794
|
+
hasInheritedProperties = true;
|
|
2795
|
+
continue;
|
|
2796
|
+
}
|
|
2790
2797
|
Object.defineProperty(prototype, property.key, { get: withSource(property.get), enumerable: true });
|
|
2791
2798
|
let valueFunction = 'v' + i++;
|
|
2792
2799
|
args.push(valueFunction);
|
|
2793
2800
|
objectLiteralProperties.push('[' + JSON.stringify(property.key) + ']:' + valueFunction + '(s)');
|
|
2794
2801
|
}
|
|
2802
|
+
if (hasInheritedProperties) {
|
|
2803
|
+
objectLiteralProperties.push('__proto__:this');
|
|
2804
|
+
}
|
|
2795
2805
|
let toObject = (new Function(...args, 'return function(s){return{' + objectLiteralProperties.join(',') + '}}')).apply(null, properties.map(prop => prop.get));
|
|
2796
2806
|
Object.defineProperty(prototype, 'toJSON', {
|
|
2797
|
-
value() {
|
|
2798
|
-
return toObject(this[sourceSymbol]);
|
|
2807
|
+
value(omitUnderscoredProperties) {
|
|
2808
|
+
return toObject.call(this, this[sourceSymbol]);
|
|
2799
2809
|
}
|
|
2800
2810
|
});
|
|
2801
2811
|
} else {
|
|
2802
2812
|
Object.defineProperty(prototype, 'toJSON', {
|
|
2803
|
-
value() {
|
|
2813
|
+
value(omitUnderscoredProperties) {
|
|
2804
2814
|
// return an enumerable object with own properties to JSON stringify
|
|
2805
2815
|
let resolved = {};
|
|
2806
2816
|
for (let i = 0, l = properties.length; i < l; i++) {
|
|
2817
|
+
// TODO: check alwaysLazyProperty
|
|
2807
2818
|
let key = properties[i].key;
|
|
2808
2819
|
|
|
2809
2820
|
resolved[key] = this[key];
|