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