msgpackr 1.9.8 → 1.9.9
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 +2 -2
- 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 +2 -2
- 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 +22 -21
- package/dist/node.cjs.map +1 -1
- package/dist/test.js +22 -21
- package/dist/test.js.map +1 -1
- package/pack.js +2 -2
- package/package.json +1 -1
- package/struct.js +20 -19
package/dist/test.js
CHANGED
|
@@ -1328,7 +1328,7 @@
|
|
|
1328
1328
|
let newSharedData = prepareStructures$1(structures, packr);
|
|
1329
1329
|
if (packr.saveStructures(newSharedData, newSharedData.isCompatible) === false) {
|
|
1330
1330
|
// get updated structures and try again if the update failed
|
|
1331
|
-
return packr.pack(value)
|
|
1331
|
+
return packr.pack(value, encodeOptions)
|
|
1332
1332
|
}
|
|
1333
1333
|
packr.lastNamedStructuresLength = sharedLength;
|
|
1334
1334
|
return returnBuffer
|
|
@@ -1922,7 +1922,7 @@
|
|
|
1922
1922
|
}
|
|
1923
1923
|
};
|
|
1924
1924
|
const writeStruct = (object, safePrototype) => {
|
|
1925
|
-
let newPosition = writeStructSlots(object, target, position, structures, makeRoom, (value, newPosition, notifySharedUpdate) => {
|
|
1925
|
+
let newPosition = writeStructSlots(object, target, start, position, structures, makeRoom, (value, newPosition, notifySharedUpdate) => {
|
|
1926
1926
|
if (notifySharedUpdate)
|
|
1927
1927
|
return hasSharedUpdate = true;
|
|
1928
1928
|
position = newPosition;
|
|
@@ -2223,7 +2223,7 @@
|
|
|
2223
2223
|
return textEncoder.encodeInto(string, target.subarray(position)).written
|
|
2224
2224
|
} : false;
|
|
2225
2225
|
setWriteStructSlots(writeStruct, prepareStructures);
|
|
2226
|
-
function writeStruct(object, target, position, structures, makeRoom, pack, packr) {
|
|
2226
|
+
function writeStruct(object, target, encodingStart, position, structures, makeRoom, pack, packr) {
|
|
2227
2227
|
let typedStructs = packr.typedStructs || (packr.typedStructs = []);
|
|
2228
2228
|
// note that we rely on pack.js to load stored structures before we get to this point
|
|
2229
2229
|
let targetView = target.dataView;
|
|
@@ -2231,12 +2231,12 @@
|
|
|
2231
2231
|
let safeEnd = target.length - 10;
|
|
2232
2232
|
let start = position;
|
|
2233
2233
|
if (position > safeEnd) {
|
|
2234
|
-
let lastStart = start;
|
|
2235
2234
|
target = makeRoom(position);
|
|
2236
2235
|
targetView = target.dataView;
|
|
2237
|
-
position -=
|
|
2238
|
-
|
|
2239
|
-
|
|
2236
|
+
position -= encodingStart;
|
|
2237
|
+
start -= encodingStart;
|
|
2238
|
+
refsStartPosition -= encodingStart;
|
|
2239
|
+
encodingStart = 0;
|
|
2240
2240
|
safeEnd = target.length - 10;
|
|
2241
2241
|
}
|
|
2242
2242
|
|
|
@@ -2274,13 +2274,13 @@
|
|
|
2274
2274
|
};
|
|
2275
2275
|
}
|
|
2276
2276
|
if (position > safeEnd) {
|
|
2277
|
-
let lastStart = start;
|
|
2278
2277
|
target = makeRoom(position);
|
|
2279
2278
|
targetView = target.dataView;
|
|
2280
|
-
position -=
|
|
2281
|
-
|
|
2282
|
-
|
|
2283
|
-
|
|
2279
|
+
position -= encodingStart;
|
|
2280
|
+
start -= encodingStart;
|
|
2281
|
+
refsStartPosition -= encodingStart;
|
|
2282
|
+
refPosition -= encodingStart;
|
|
2283
|
+
encodingStart = 0;
|
|
2284
2284
|
safeEnd = target.length - 10;
|
|
2285
2285
|
}
|
|
2286
2286
|
switch (typeof value) {
|
|
@@ -2319,13 +2319,13 @@
|
|
|
2319
2319
|
let strLength = value.length;
|
|
2320
2320
|
refOffset = refPosition - refsStartPosition;
|
|
2321
2321
|
if ((strLength << 2) + refPosition > safeEnd) {
|
|
2322
|
-
let lastStart = start;
|
|
2323
2322
|
target = makeRoom((strLength << 2) + refPosition);
|
|
2324
2323
|
targetView = target.dataView;
|
|
2325
|
-
position -=
|
|
2326
|
-
|
|
2327
|
-
|
|
2328
|
-
|
|
2324
|
+
position -= encodingStart;
|
|
2325
|
+
start -= encodingStart;
|
|
2326
|
+
refsStartPosition -= encodingStart;
|
|
2327
|
+
refPosition -= encodingStart;
|
|
2328
|
+
encodingStart = 0;
|
|
2329
2329
|
safeEnd = target.length - 10;
|
|
2330
2330
|
}
|
|
2331
2331
|
if (strLength > ((0xff00 + refOffset) >> 2)) {
|
|
@@ -2484,9 +2484,10 @@
|
|
|
2484
2484
|
refPosition = newPosition.position;
|
|
2485
2485
|
targetView = newPosition.targetView;
|
|
2486
2486
|
target = newPosition.target;
|
|
2487
|
-
refsStartPosition -=
|
|
2488
|
-
position -=
|
|
2489
|
-
start
|
|
2487
|
+
refsStartPosition -= encodingStart;
|
|
2488
|
+
position -= encodingStart;
|
|
2489
|
+
start -= encodingStart;
|
|
2490
|
+
encodingStart = 0;
|
|
2490
2491
|
} else
|
|
2491
2492
|
refPosition = newPosition;
|
|
2492
2493
|
if (size === 2) {
|
|
@@ -2560,7 +2561,7 @@
|
|
|
2560
2561
|
if (refsStartPosition === refPosition)
|
|
2561
2562
|
return position; // no refs
|
|
2562
2563
|
typedStructs.lastStringStart = position - start;
|
|
2563
|
-
return writeStruct(object, target, start, structures, makeRoom, pack, packr);
|
|
2564
|
+
return writeStruct(object, target, encodingStart, start, structures, makeRoom, pack, packr);
|
|
2564
2565
|
}
|
|
2565
2566
|
return refPosition;
|
|
2566
2567
|
}
|