msgpackr 1.7.0-alpha4 → 1.7.0-alpha7
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.js +6 -4
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +59 -59
- package/dist/index.min.js.map +1 -1
- package/dist/node.cjs +89 -33
- package/dist/node.cjs.map +1 -1
- package/dist/test.js +95 -35
- package/dist/test.js.map +1 -1
- package/package.json +1 -1
- package/struct.js +78 -28
- package/unpack.js +11 -6
package/dist/index.js
CHANGED
|
@@ -94,7 +94,7 @@
|
|
|
94
94
|
currentUnpackr = this;
|
|
95
95
|
if (this.structures) {
|
|
96
96
|
currentStructures = this.structures;
|
|
97
|
-
return checkedRead()
|
|
97
|
+
return checkedRead(options)
|
|
98
98
|
} else if (!currentStructures || currentStructures.length > 0) {
|
|
99
99
|
currentStructures = [];
|
|
100
100
|
}
|
|
@@ -103,7 +103,7 @@
|
|
|
103
103
|
if (!currentStructures || currentStructures.length > 0)
|
|
104
104
|
currentStructures = [];
|
|
105
105
|
}
|
|
106
|
-
return checkedRead()
|
|
106
|
+
return checkedRead(options)
|
|
107
107
|
}
|
|
108
108
|
unpackMultiple(source, forEach) {
|
|
109
109
|
let values, lastPosition = 0;
|
|
@@ -167,7 +167,7 @@
|
|
|
167
167
|
return this.unpack(source, end)
|
|
168
168
|
}
|
|
169
169
|
}
|
|
170
|
-
function checkedRead() {
|
|
170
|
+
function checkedRead(options) {
|
|
171
171
|
try {
|
|
172
172
|
if (!currentUnpackr.trusted && !sequentialMode) {
|
|
173
173
|
let sharedLength = currentStructures.sharedLength || 0;
|
|
@@ -177,6 +177,8 @@
|
|
|
177
177
|
let result;
|
|
178
178
|
if (currentUnpackr.randomAccessStructure && src[position] < 0x40 && src[position] >= 0x20 && readStruct) {
|
|
179
179
|
result = readStruct(src, position, srcEnd, currentUnpackr);
|
|
180
|
+
if (!(options && options.lazy) && result)
|
|
181
|
+
result = result.toJSON();
|
|
180
182
|
position = srcEnd;
|
|
181
183
|
} else
|
|
182
184
|
result = read();
|
|
@@ -200,7 +202,7 @@
|
|
|
200
202
|
// else more to read, but we are reading sequentially, so don't clear source yet
|
|
201
203
|
return result
|
|
202
204
|
} catch(error) {
|
|
203
|
-
if (currentStructures
|
|
205
|
+
if (currentStructures?.restoreStructures)
|
|
204
206
|
restoreStructures();
|
|
205
207
|
clearSource();
|
|
206
208
|
if (error instanceof RangeError || error.message.startsWith('Unexpected end of buffer') || position > srcEnd) {
|