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/test.js
CHANGED
|
@@ -2284,25 +2284,28 @@
|
|
|
2284
2284
|
switch (typeof value) {
|
|
2285
2285
|
case 'number':
|
|
2286
2286
|
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) {
|
|
2287
|
+
// first check to see if we are using a lot of ids and should default to wide/common format
|
|
2288
|
+
if (nextId < 200 || !nextTransition.num64) {
|
|
2289
|
+
if (number >> 0 === number && number < 0x20000000 && number > -0x1f000000) {
|
|
2290
|
+
if (number < 0xf6 && number >= 0 && (nextTransition.num8 && !(nextId > 200 && nextTransition.num32) || number < 0x20 && !nextTransition.num32)) {
|
|
2291
|
+
transition = nextTransition.num8 || createTypeTransition(nextTransition, NUMBER, 1);
|
|
2292
|
+
target[position++] = number;
|
|
2293
|
+
} else {
|
|
2303
2294
|
transition = nextTransition.num32 || createTypeTransition(nextTransition, NUMBER, 4);
|
|
2295
|
+
targetView.setUint32(position, number, true);
|
|
2304
2296
|
position += 4;
|
|
2305
|
-
|
|
2297
|
+
}
|
|
2298
|
+
break;
|
|
2299
|
+
} else if (number < 0x100000000 && number >= -0x80000000) {
|
|
2300
|
+
targetView.setFloat32(position, number, true);
|
|
2301
|
+
if (float32Headers[target[position + 3] >>> 5]) {
|
|
2302
|
+
let xShifted;
|
|
2303
|
+
// this checks for rounding of numbers that were encoded in 32-bit float to nearest significant decimal digit that could be preserved
|
|
2304
|
+
if (((xShifted = number * mult10[((target[position + 3] & 0x7f) << 1) | (target[position + 2] >> 7)]) >> 0) === xShifted) {
|
|
2305
|
+
transition = nextTransition.num32 || createTypeTransition(nextTransition, NUMBER, 4);
|
|
2306
|
+
position += 4;
|
|
2307
|
+
break;
|
|
2308
|
+
}
|
|
2306
2309
|
}
|
|
2307
2310
|
}
|
|
2308
2311
|
}
|