msgpackr 1.9.5 → 1.9.7
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 +45 -36
- package/dist/node.cjs.map +1 -1
- package/dist/test.js +45 -36
- package/dist/test.js.map +1 -1
- package/pack.js +25 -19
- package/package.json +1 -1
- package/struct.js +20 -17
package/dist/index.js
CHANGED
|
@@ -1257,25 +1257,9 @@
|
|
|
1257
1257
|
return target.subarray(start, position) // position can change if we call pack again in saveStructures, so we get the buffer now
|
|
1258
1258
|
} finally {
|
|
1259
1259
|
if (structures) {
|
|
1260
|
-
|
|
1261
|
-
serializationsSinceTransitionRebuild++;
|
|
1262
|
-
let sharedLength = structures.sharedLength || 0;
|
|
1263
|
-
if (structures.length > sharedLength && !isSequential)
|
|
1264
|
-
structures.length = sharedLength;
|
|
1265
|
-
if (transitionsCount > 10000) {
|
|
1266
|
-
// force a rebuild occasionally after a lot of transitions so it can get cleaned up
|
|
1267
|
-
structures.transitions = null;
|
|
1268
|
-
serializationsSinceTransitionRebuild = 0;
|
|
1269
|
-
transitionsCount = 0;
|
|
1270
|
-
if (recordIdsToRemove.length > 0)
|
|
1271
|
-
recordIdsToRemove = [];
|
|
1272
|
-
} else if (recordIdsToRemove.length > 0 && !isSequential) {
|
|
1273
|
-
for (let i = 0, l = recordIdsToRemove.length; i < l; i++) {
|
|
1274
|
-
recordIdsToRemove[i][RECORD_SYMBOL] = 0;
|
|
1275
|
-
}
|
|
1276
|
-
recordIdsToRemove = [];
|
|
1277
|
-
}
|
|
1260
|
+
resetStructures();
|
|
1278
1261
|
if (hasSharedUpdate && packr.saveStructures) {
|
|
1262
|
+
let sharedLength = structures.sharedLength || 0;
|
|
1279
1263
|
// we can't rely on start/end with REUSE_BUFFER_MODE since they will (probably) change when we save
|
|
1280
1264
|
let returnBuffer = target.subarray(start, position);
|
|
1281
1265
|
let newSharedData = prepareStructures(structures, packr);
|
|
@@ -1291,6 +1275,26 @@
|
|
|
1291
1275
|
position = start;
|
|
1292
1276
|
}
|
|
1293
1277
|
};
|
|
1278
|
+
const resetStructures = () => {
|
|
1279
|
+
if (serializationsSinceTransitionRebuild < 10)
|
|
1280
|
+
serializationsSinceTransitionRebuild++;
|
|
1281
|
+
let sharedLength = structures.sharedLength || 0;
|
|
1282
|
+
if (structures.length > sharedLength && !isSequential)
|
|
1283
|
+
structures.length = sharedLength;
|
|
1284
|
+
if (transitionsCount > 10000) {
|
|
1285
|
+
// force a rebuild occasionally after a lot of transitions so it can get cleaned up
|
|
1286
|
+
structures.transitions = null;
|
|
1287
|
+
serializationsSinceTransitionRebuild = 0;
|
|
1288
|
+
transitionsCount = 0;
|
|
1289
|
+
if (recordIdsToRemove.length > 0)
|
|
1290
|
+
recordIdsToRemove = [];
|
|
1291
|
+
} else if (recordIdsToRemove.length > 0 && !isSequential) {
|
|
1292
|
+
for (let i = 0, l = recordIdsToRemove.length; i < l; i++) {
|
|
1293
|
+
recordIdsToRemove[i][RECORD_SYMBOL] = 0;
|
|
1294
|
+
}
|
|
1295
|
+
recordIdsToRemove = [];
|
|
1296
|
+
}
|
|
1297
|
+
};
|
|
1294
1298
|
const packArray = (value) => {
|
|
1295
1299
|
var length = value.length;
|
|
1296
1300
|
if (length < 0x10) {
|
|
@@ -1740,8 +1744,9 @@
|
|
|
1740
1744
|
}
|
|
1741
1745
|
// now write the values
|
|
1742
1746
|
for (let key in object)
|
|
1743
|
-
if (safePrototype || object.hasOwnProperty(key))
|
|
1747
|
+
if (safePrototype || object.hasOwnProperty(key)) {
|
|
1744
1748
|
pack(object[key]);
|
|
1749
|
+
}
|
|
1745
1750
|
};
|
|
1746
1751
|
|
|
1747
1752
|
// craete reference to useRecords if useRecords is a function
|
|
@@ -1860,6 +1865,7 @@
|
|
|
1860
1865
|
position = newPosition;
|
|
1861
1866
|
let startTarget = target;
|
|
1862
1867
|
pack(value);
|
|
1868
|
+
resetStructures();
|
|
1863
1869
|
if (startTarget !== target) {
|
|
1864
1870
|
return { position, targetView, target }; // indicate the buffer was re-allocated
|
|
1865
1871
|
}
|