msgpackr 1.9.5 → 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 +25 -19
- package/dist/node.cjs.map +1 -1
- package/dist/test.js +25 -19
- package/dist/test.js.map +1 -1
- package/pack.js +25 -19
- package/package.json +1 -1
package/dist/node.cjs
CHANGED
|
@@ -1324,25 +1324,9 @@ class Packr extends Unpackr {
|
|
|
1324
1324
|
return target.subarray(start, position) // position can change if we call pack again in saveStructures, so we get the buffer now
|
|
1325
1325
|
} finally {
|
|
1326
1326
|
if (structures) {
|
|
1327
|
-
|
|
1328
|
-
serializationsSinceTransitionRebuild++;
|
|
1329
|
-
let sharedLength = structures.sharedLength || 0;
|
|
1330
|
-
if (structures.length > sharedLength && !isSequential)
|
|
1331
|
-
structures.length = sharedLength;
|
|
1332
|
-
if (transitionsCount > 10000) {
|
|
1333
|
-
// force a rebuild occasionally after a lot of transitions so it can get cleaned up
|
|
1334
|
-
structures.transitions = null;
|
|
1335
|
-
serializationsSinceTransitionRebuild = 0;
|
|
1336
|
-
transitionsCount = 0;
|
|
1337
|
-
if (recordIdsToRemove.length > 0)
|
|
1338
|
-
recordIdsToRemove = [];
|
|
1339
|
-
} else if (recordIdsToRemove.length > 0 && !isSequential) {
|
|
1340
|
-
for (let i = 0, l = recordIdsToRemove.length; i < l; i++) {
|
|
1341
|
-
recordIdsToRemove[i][RECORD_SYMBOL] = 0;
|
|
1342
|
-
}
|
|
1343
|
-
recordIdsToRemove = [];
|
|
1344
|
-
}
|
|
1327
|
+
resetStructures();
|
|
1345
1328
|
if (hasSharedUpdate && packr.saveStructures) {
|
|
1329
|
+
let sharedLength = structures.sharedLength || 0;
|
|
1346
1330
|
// we can't rely on start/end with REUSE_BUFFER_MODE since they will (probably) change when we save
|
|
1347
1331
|
let returnBuffer = target.subarray(start, position);
|
|
1348
1332
|
let newSharedData = prepareStructures$1(structures, packr);
|
|
@@ -1358,6 +1342,26 @@ class Packr extends Unpackr {
|
|
|
1358
1342
|
position = start;
|
|
1359
1343
|
}
|
|
1360
1344
|
};
|
|
1345
|
+
const resetStructures = () => {
|
|
1346
|
+
if (serializationsSinceTransitionRebuild < 10)
|
|
1347
|
+
serializationsSinceTransitionRebuild++;
|
|
1348
|
+
let sharedLength = structures.sharedLength || 0;
|
|
1349
|
+
if (structures.length > sharedLength && !isSequential)
|
|
1350
|
+
structures.length = sharedLength;
|
|
1351
|
+
if (transitionsCount > 10000) {
|
|
1352
|
+
// force a rebuild occasionally after a lot of transitions so it can get cleaned up
|
|
1353
|
+
structures.transitions = null;
|
|
1354
|
+
serializationsSinceTransitionRebuild = 0;
|
|
1355
|
+
transitionsCount = 0;
|
|
1356
|
+
if (recordIdsToRemove.length > 0)
|
|
1357
|
+
recordIdsToRemove = [];
|
|
1358
|
+
} else if (recordIdsToRemove.length > 0 && !isSequential) {
|
|
1359
|
+
for (let i = 0, l = recordIdsToRemove.length; i < l; i++) {
|
|
1360
|
+
recordIdsToRemove[i][RECORD_SYMBOL] = 0;
|
|
1361
|
+
}
|
|
1362
|
+
recordIdsToRemove = [];
|
|
1363
|
+
}
|
|
1364
|
+
};
|
|
1361
1365
|
const packArray = (value) => {
|
|
1362
1366
|
var length = value.length;
|
|
1363
1367
|
if (length < 0x10) {
|
|
@@ -1807,8 +1811,9 @@ class Packr extends Unpackr {
|
|
|
1807
1811
|
}
|
|
1808
1812
|
// now write the values
|
|
1809
1813
|
for (let key in object)
|
|
1810
|
-
if (safePrototype || object.hasOwnProperty(key))
|
|
1814
|
+
if (safePrototype || object.hasOwnProperty(key)) {
|
|
1811
1815
|
pack(object[key]);
|
|
1816
|
+
}
|
|
1812
1817
|
};
|
|
1813
1818
|
|
|
1814
1819
|
// craete reference to useRecords if useRecords is a function
|
|
@@ -1927,6 +1932,7 @@ class Packr extends Unpackr {
|
|
|
1927
1932
|
position = newPosition;
|
|
1928
1933
|
let startTarget = target;
|
|
1929
1934
|
pack(value);
|
|
1935
|
+
resetStructures();
|
|
1930
1936
|
if (startTarget !== target) {
|
|
1931
1937
|
return { position, targetView, target }; // indicate the buffer was re-allocated
|
|
1932
1938
|
}
|