msgpackr 1.9.5-debug.1 → 1.9.6
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 +25 -19
- 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 +25 -19
- 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 +30 -29
- package/dist/node.cjs.map +1 -1
- package/dist/test.js +30 -29
- package/dist/test.js.map +1 -1
- package/pack.js +25 -19
- package/package.json +1 -1
- package/struct.js +5 -10
package/pack.js
CHANGED
|
@@ -172,25 +172,9 @@ export class Packr extends Unpackr {
|
|
|
172
172
|
return target.subarray(start, position) // position can change if we call pack again in saveStructures, so we get the buffer now
|
|
173
173
|
} finally {
|
|
174
174
|
if (structures) {
|
|
175
|
-
|
|
176
|
-
serializationsSinceTransitionRebuild++
|
|
177
|
-
let sharedLength = structures.sharedLength || 0
|
|
178
|
-
if (structures.length > sharedLength && !isSequential)
|
|
179
|
-
structures.length = sharedLength
|
|
180
|
-
if (transitionsCount > 10000) {
|
|
181
|
-
// force a rebuild occasionally after a lot of transitions so it can get cleaned up
|
|
182
|
-
structures.transitions = null
|
|
183
|
-
serializationsSinceTransitionRebuild = 0
|
|
184
|
-
transitionsCount = 0
|
|
185
|
-
if (recordIdsToRemove.length > 0)
|
|
186
|
-
recordIdsToRemove = []
|
|
187
|
-
} else if (recordIdsToRemove.length > 0 && !isSequential) {
|
|
188
|
-
for (let i = 0, l = recordIdsToRemove.length; i < l; i++) {
|
|
189
|
-
recordIdsToRemove[i][RECORD_SYMBOL] = 0
|
|
190
|
-
}
|
|
191
|
-
recordIdsToRemove = []
|
|
192
|
-
}
|
|
175
|
+
resetStructures();
|
|
193
176
|
if (hasSharedUpdate && packr.saveStructures) {
|
|
177
|
+
let sharedLength = structures.sharedLength || 0
|
|
194
178
|
// we can't rely on start/end with REUSE_BUFFER_MODE since they will (probably) change when we save
|
|
195
179
|
let returnBuffer = target.subarray(start, position)
|
|
196
180
|
let newSharedData = prepareStructures(structures, packr);
|
|
@@ -206,6 +190,26 @@ export class Packr extends Unpackr {
|
|
|
206
190
|
position = start
|
|
207
191
|
}
|
|
208
192
|
}
|
|
193
|
+
const resetStructures = () => {
|
|
194
|
+
if (serializationsSinceTransitionRebuild < 10)
|
|
195
|
+
serializationsSinceTransitionRebuild++
|
|
196
|
+
let sharedLength = structures.sharedLength || 0
|
|
197
|
+
if (structures.length > sharedLength && !isSequential)
|
|
198
|
+
structures.length = sharedLength
|
|
199
|
+
if (transitionsCount > 10000) {
|
|
200
|
+
// force a rebuild occasionally after a lot of transitions so it can get cleaned up
|
|
201
|
+
structures.transitions = null
|
|
202
|
+
serializationsSinceTransitionRebuild = 0
|
|
203
|
+
transitionsCount = 0
|
|
204
|
+
if (recordIdsToRemove.length > 0)
|
|
205
|
+
recordIdsToRemove = []
|
|
206
|
+
} else if (recordIdsToRemove.length > 0 && !isSequential) {
|
|
207
|
+
for (let i = 0, l = recordIdsToRemove.length; i < l; i++) {
|
|
208
|
+
recordIdsToRemove[i][RECORD_SYMBOL] = 0
|
|
209
|
+
}
|
|
210
|
+
recordIdsToRemove = []
|
|
211
|
+
}
|
|
212
|
+
}
|
|
209
213
|
const packArray = (value) => {
|
|
210
214
|
var length = value.length
|
|
211
215
|
if (length < 0x10) {
|
|
@@ -655,8 +659,9 @@ export class Packr extends Unpackr {
|
|
|
655
659
|
}
|
|
656
660
|
// now write the values
|
|
657
661
|
for (let key in object)
|
|
658
|
-
if (safePrototype || object.hasOwnProperty(key))
|
|
662
|
+
if (safePrototype || object.hasOwnProperty(key)) {
|
|
659
663
|
pack(object[key])
|
|
664
|
+
}
|
|
660
665
|
}
|
|
661
666
|
|
|
662
667
|
// craete reference to useRecords if useRecords is a function
|
|
@@ -775,6 +780,7 @@ export class Packr extends Unpackr {
|
|
|
775
780
|
position = newPosition;
|
|
776
781
|
let startTarget = target;
|
|
777
782
|
pack(value);
|
|
783
|
+
resetStructures();
|
|
778
784
|
if (startTarget !== target) {
|
|
779
785
|
return { position, targetView, target }; // indicate the buffer was re-allocated
|
|
780
786
|
}
|
package/package.json
CHANGED
package/struct.js
CHANGED
|
@@ -717,16 +717,11 @@ function readStruct(src, position, srcEnd, unpackr) {
|
|
|
717
717
|
objectLiteralProperties.push('__proto__:this');
|
|
718
718
|
}
|
|
719
719
|
let toObject = (new Function(...args, 'return function(s){return{' + objectLiteralProperties.join(',') + '}}')).apply(null, properties.map(prop => prop.get));
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
});
|
|
726
|
-
} catch(error) {
|
|
727
|
-
error.message += ' setting properties ' + JSON.stringify(properties);
|
|
728
|
-
throw error;
|
|
729
|
-
}
|
|
720
|
+
Object.defineProperty(prototype, 'toJSON', {
|
|
721
|
+
value(omitUnderscoredProperties) {
|
|
722
|
+
return toObject.call(this, this[sourceSymbol]);
|
|
723
|
+
}
|
|
724
|
+
});
|
|
730
725
|
} else {
|
|
731
726
|
Object.defineProperty(prototype, 'toJSON', {
|
|
732
727
|
value(omitUnderscoredProperties) {
|