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/pack.js
CHANGED
|
@@ -181,7 +181,7 @@ export class Packr extends Unpackr {
|
|
|
181
181
|
let newSharedData = prepareStructures(structures, packr);
|
|
182
182
|
if (packr.saveStructures(newSharedData, newSharedData.isCompatible) === false) {
|
|
183
183
|
// get updated structures and try again if the update failed
|
|
184
|
-
return packr.pack(value)
|
|
184
|
+
return packr.pack(value, encodeOptions)
|
|
185
185
|
}
|
|
186
186
|
packr.lastNamedStructuresLength = sharedLength
|
|
187
187
|
return returnBuffer
|
|
@@ -775,7 +775,7 @@ export class Packr extends Unpackr {
|
|
|
775
775
|
}
|
|
776
776
|
}
|
|
777
777
|
const writeStruct = (object, safePrototype) => {
|
|
778
|
-
let newPosition = writeStructSlots(object, target, position, structures, makeRoom, (value, newPosition, notifySharedUpdate) => {
|
|
778
|
+
let newPosition = writeStructSlots(object, target, start, position, structures, makeRoom, (value, newPosition, notifySharedUpdate) => {
|
|
779
779
|
if (notifySharedUpdate)
|
|
780
780
|
return hasSharedUpdate = true;
|
|
781
781
|
position = newPosition;
|
package/package.json
CHANGED
package/struct.js
CHANGED
|
@@ -69,7 +69,7 @@ const encodeUtf8 = hasNodeBuffer ? function(target, string, position) {
|
|
|
69
69
|
const TYPE = Symbol('type');
|
|
70
70
|
const PARENT = Symbol('parent');
|
|
71
71
|
setWriteStructSlots(writeStruct, prepareStructures);
|
|
72
|
-
function writeStruct(object, target, position, structures, makeRoom, pack, packr) {
|
|
72
|
+
function writeStruct(object, target, encodingStart, position, structures, makeRoom, pack, packr) {
|
|
73
73
|
let typedStructs = packr.typedStructs || (packr.typedStructs = []);
|
|
74
74
|
// note that we rely on pack.js to load stored structures before we get to this point
|
|
75
75
|
let targetView = target.dataView;
|
|
@@ -77,12 +77,12 @@ function writeStruct(object, target, position, structures, makeRoom, pack, packr
|
|
|
77
77
|
let safeEnd = target.length - 10;
|
|
78
78
|
let start = position;
|
|
79
79
|
if (position > safeEnd) {
|
|
80
|
-
let lastStart = start;
|
|
81
80
|
target = makeRoom(position);
|
|
82
81
|
targetView = target.dataView;
|
|
83
|
-
position -=
|
|
84
|
-
|
|
85
|
-
|
|
82
|
+
position -= encodingStart;
|
|
83
|
+
start -= encodingStart;
|
|
84
|
+
refsStartPosition -= encodingStart;
|
|
85
|
+
encodingStart = 0;
|
|
86
86
|
safeEnd = target.length - 10;
|
|
87
87
|
}
|
|
88
88
|
|
|
@@ -120,13 +120,13 @@ function writeStruct(object, target, position, structures, makeRoom, pack, packr
|
|
|
120
120
|
};
|
|
121
121
|
}
|
|
122
122
|
if (position > safeEnd) {
|
|
123
|
-
let lastStart = start;
|
|
124
123
|
target = makeRoom(position);
|
|
125
124
|
targetView = target.dataView;
|
|
126
|
-
position -=
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
125
|
+
position -= encodingStart;
|
|
126
|
+
start -= encodingStart;
|
|
127
|
+
refsStartPosition -= encodingStart;
|
|
128
|
+
refPosition -= encodingStart;
|
|
129
|
+
encodingStart = 0;
|
|
130
130
|
safeEnd = target.length - 10
|
|
131
131
|
}
|
|
132
132
|
switch (typeof value) {
|
|
@@ -165,13 +165,13 @@ function writeStruct(object, target, position, structures, makeRoom, pack, packr
|
|
|
165
165
|
let strLength = value.length;
|
|
166
166
|
refOffset = refPosition - refsStartPosition;
|
|
167
167
|
if ((strLength << 2) + refPosition > safeEnd) {
|
|
168
|
-
let lastStart = start;
|
|
169
168
|
target = makeRoom((strLength << 2) + refPosition);
|
|
170
169
|
targetView = target.dataView;
|
|
171
|
-
position -=
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
170
|
+
position -= encodingStart;
|
|
171
|
+
start -= encodingStart;
|
|
172
|
+
refsStartPosition -= encodingStart;
|
|
173
|
+
refPosition -= encodingStart;
|
|
174
|
+
encodingStart = 0;
|
|
175
175
|
safeEnd = target.length - 10
|
|
176
176
|
}
|
|
177
177
|
if (strLength > ((0xff00 + refOffset) >> 2)) {
|
|
@@ -330,9 +330,10 @@ function writeStruct(object, target, position, structures, makeRoom, pack, packr
|
|
|
330
330
|
refPosition = newPosition.position;
|
|
331
331
|
targetView = newPosition.targetView;
|
|
332
332
|
target = newPosition.target;
|
|
333
|
-
refsStartPosition -=
|
|
334
|
-
position -=
|
|
335
|
-
start
|
|
333
|
+
refsStartPosition -= encodingStart;
|
|
334
|
+
position -= encodingStart;
|
|
335
|
+
start -= encodingStart;
|
|
336
|
+
encodingStart = 0;
|
|
336
337
|
} else
|
|
337
338
|
refPosition = newPosition;
|
|
338
339
|
if (size === 2) {
|
|
@@ -406,7 +407,7 @@ function writeStruct(object, target, position, structures, makeRoom, pack, packr
|
|
|
406
407
|
if (refsStartPosition === refPosition)
|
|
407
408
|
return position; // no refs
|
|
408
409
|
typedStructs.lastStringStart = position - start;
|
|
409
|
-
return writeStruct(object, target, start, structures, makeRoom, pack, packr);
|
|
410
|
+
return writeStruct(object, target, encodingStart, start, structures, makeRoom, pack, packr);
|
|
410
411
|
}
|
|
411
412
|
return refPosition;
|
|
412
413
|
}
|