msgpackr 1.9.6 → 1.9.8
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 +4 -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 +4 -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 +24 -19
- package/dist/node.cjs.map +1 -1
- package/dist/test.js +24 -19
- package/dist/test.js.map +1 -1
- package/dist/unpack-no-eval.cjs +2 -2
- package/dist/unpack-no-eval.cjs.map +1 -1
- package/pack.js +2 -0
- package/package.json +1 -1
- package/struct.js +20 -17
- package/unpack.js +2 -2
package/dist/test.js
CHANGED
|
@@ -173,8 +173,8 @@
|
|
|
173
173
|
}
|
|
174
174
|
return this.structures = loadedStructures
|
|
175
175
|
}
|
|
176
|
-
decode(source,
|
|
177
|
-
return this.unpack(source,
|
|
176
|
+
decode(source, options) {
|
|
177
|
+
return this.unpack(source, options)
|
|
178
178
|
}
|
|
179
179
|
};
|
|
180
180
|
function checkedRead(options) {
|
|
@@ -1226,6 +1226,7 @@
|
|
|
1226
1226
|
} else
|
|
1227
1227
|
position = (position + 7) & 0x7ffffff8; // Word align to make any future copying of this buffer faster
|
|
1228
1228
|
start = position;
|
|
1229
|
+
if (encodeOptions & RESERVE_START_SPACE) position += (encodeOptions & 0xff);
|
|
1229
1230
|
referenceMap = packr.structuredClone ? new Map() : null;
|
|
1230
1231
|
if (packr.bundleStrings && typeof value !== 'string') {
|
|
1231
1232
|
bundledStrings = [];
|
|
@@ -2191,6 +2192,7 @@
|
|
|
2191
2192
|
defaultPackr.pack;
|
|
2192
2193
|
const REUSE_BUFFER_MODE = 512;
|
|
2193
2194
|
const RESET_BUFFER_MODE = 1024;
|
|
2195
|
+
const RESERVE_START_SPACE = 2048;
|
|
2194
2196
|
|
|
2195
2197
|
const ASCII = 3; // the MIBenum from https://www.iana.org/assignments/character-sets/character-sets.xhtml (and other character encodings could be referenced by MIBenum)
|
|
2196
2198
|
const NUMBER = 0;
|
|
@@ -2284,25 +2286,28 @@
|
|
|
2284
2286
|
switch (typeof value) {
|
|
2285
2287
|
case 'number':
|
|
2286
2288
|
let number = value;
|
|
2287
|
-
if
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
|
|
2294
|
-
position += 4;
|
|
2295
|
-
}
|
|
2296
|
-
break;
|
|
2297
|
-
} else if (number < 0x100000000 && number >= -0x80000000) {
|
|
2298
|
-
targetView.setFloat32(position, number, true);
|
|
2299
|
-
if (float32Headers[target[position + 3] >>> 5]) {
|
|
2300
|
-
let xShifted;
|
|
2301
|
-
// this checks for rounding of numbers that were encoded in 32-bit float to nearest significant decimal digit that could be preserved
|
|
2302
|
-
if (((xShifted = number * mult10[((target[position + 3] & 0x7f) << 1) | (target[position + 2] >> 7)]) >> 0) === xShifted) {
|
|
2289
|
+
// first check to see if we are using a lot of ids and should default to wide/common format
|
|
2290
|
+
if (nextId < 200 || !nextTransition.num64) {
|
|
2291
|
+
if (number >> 0 === number && number < 0x20000000 && number > -0x1f000000) {
|
|
2292
|
+
if (number < 0xf6 && number >= 0 && (nextTransition.num8 && !(nextId > 200 && nextTransition.num32) || number < 0x20 && !nextTransition.num32)) {
|
|
2293
|
+
transition = nextTransition.num8 || createTypeTransition(nextTransition, NUMBER, 1);
|
|
2294
|
+
target[position++] = number;
|
|
2295
|
+
} else {
|
|
2303
2296
|
transition = nextTransition.num32 || createTypeTransition(nextTransition, NUMBER, 4);
|
|
2297
|
+
targetView.setUint32(position, number, true);
|
|
2304
2298
|
position += 4;
|
|
2305
|
-
|
|
2299
|
+
}
|
|
2300
|
+
break;
|
|
2301
|
+
} else if (number < 0x100000000 && number >= -0x80000000) {
|
|
2302
|
+
targetView.setFloat32(position, number, true);
|
|
2303
|
+
if (float32Headers[target[position + 3] >>> 5]) {
|
|
2304
|
+
let xShifted;
|
|
2305
|
+
// this checks for rounding of numbers that were encoded in 32-bit float to nearest significant decimal digit that could be preserved
|
|
2306
|
+
if (((xShifted = number * mult10[((target[position + 3] & 0x7f) << 1) | (target[position + 2] >> 7)]) >> 0) === xShifted) {
|
|
2307
|
+
transition = nextTransition.num32 || createTypeTransition(nextTransition, NUMBER, 4);
|
|
2308
|
+
position += 4;
|
|
2309
|
+
break;
|
|
2310
|
+
}
|
|
2306
2311
|
}
|
|
2307
2312
|
}
|
|
2308
2313
|
}
|