msgpackr 1.9.6 → 1.9.7
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/node.cjs +20 -17
- package/dist/node.cjs.map +1 -1
- package/dist/test.js +20 -17
- package/dist/test.js.map +1 -1
- package/package.json +1 -1
- package/struct.js +20 -17
package/dist/node.cjs
CHANGED
|
@@ -2291,25 +2291,28 @@ function writeStruct(object, target, position, structures, makeRoom, pack, packr
|
|
|
2291
2291
|
switch (typeof value) {
|
|
2292
2292
|
case 'number':
|
|
2293
2293
|
let number = value;
|
|
2294
|
-
if
|
|
2295
|
-
|
|
2296
|
-
|
|
2297
|
-
|
|
2298
|
-
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
position += 4;
|
|
2302
|
-
}
|
|
2303
|
-
break;
|
|
2304
|
-
} else if (number < 0x100000000 && number >= -0x80000000) {
|
|
2305
|
-
targetView.setFloat32(position, number, true);
|
|
2306
|
-
if (float32Headers[target[position + 3] >>> 5]) {
|
|
2307
|
-
let xShifted;
|
|
2308
|
-
// this checks for rounding of numbers that were encoded in 32-bit float to nearest significant decimal digit that could be preserved
|
|
2309
|
-
if (((xShifted = number * mult10[((target[position + 3] & 0x7f) << 1) | (target[position + 2] >> 7)]) >> 0) === xShifted) {
|
|
2294
|
+
// first check to see if we are using a lot of ids and should default to wide/common format
|
|
2295
|
+
if (nextId < 200 || !nextTransition.num64) {
|
|
2296
|
+
if (number >> 0 === number && number < 0x20000000 && number > -0x1f000000) {
|
|
2297
|
+
if (number < 0xf6 && number >= 0 && (nextTransition.num8 && !(nextId > 200 && nextTransition.num32) || number < 0x20 && !nextTransition.num32)) {
|
|
2298
|
+
transition = nextTransition.num8 || createTypeTransition(nextTransition, NUMBER, 1);
|
|
2299
|
+
target[position++] = number;
|
|
2300
|
+
} else {
|
|
2310
2301
|
transition = nextTransition.num32 || createTypeTransition(nextTransition, NUMBER, 4);
|
|
2302
|
+
targetView.setUint32(position, number, true);
|
|
2311
2303
|
position += 4;
|
|
2312
|
-
|
|
2304
|
+
}
|
|
2305
|
+
break;
|
|
2306
|
+
} else if (number < 0x100000000 && number >= -0x80000000) {
|
|
2307
|
+
targetView.setFloat32(position, number, true);
|
|
2308
|
+
if (float32Headers[target[position + 3] >>> 5]) {
|
|
2309
|
+
let xShifted;
|
|
2310
|
+
// this checks for rounding of numbers that were encoded in 32-bit float to nearest significant decimal digit that could be preserved
|
|
2311
|
+
if (((xShifted = number * mult10[((target[position + 3] & 0x7f) << 1) | (target[position + 2] >> 7)]) >> 0) === xShifted) {
|
|
2312
|
+
transition = nextTransition.num32 || createTypeTransition(nextTransition, NUMBER, 4);
|
|
2313
|
+
position += 4;
|
|
2314
|
+
break;
|
|
2315
|
+
}
|
|
2313
2316
|
}
|
|
2314
2317
|
}
|
|
2315
2318
|
}
|