msgpackr 1.9.3 → 1.9.4
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 +14 -4
- 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 +14 -4
- 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 +14 -4
- package/dist/node.cjs.map +1 -1
- package/dist/test.js +21 -4
- package/dist/test.js.map +1 -1
- package/index.d.cts +2 -1
- package/index.d.ts +2 -1
- package/pack.js +14 -4
- package/package.json +1 -1
package/dist/index-no-eval.cjs
CHANGED
|
@@ -1620,7 +1620,7 @@
|
|
|
1620
1620
|
}
|
|
1621
1621
|
};
|
|
1622
1622
|
|
|
1623
|
-
const writePlainObject = this.variableMapSize ? (object) => {
|
|
1623
|
+
const writePlainObject = (this.variableMapSize || this.coercibleKeyAsNumber) ? (object) => {
|
|
1624
1624
|
// this method is slightly slower, but generates "preferred serialization" (optimally small for smaller objects)
|
|
1625
1625
|
let keys = Object.keys(object);
|
|
1626
1626
|
let length = keys.length;
|
|
@@ -1636,9 +1636,19 @@
|
|
|
1636
1636
|
position += 4;
|
|
1637
1637
|
}
|
|
1638
1638
|
let key;
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1639
|
+
if (this.coercibleKeyAsNumber) {
|
|
1640
|
+
for (let i = 0; i < length; i++) {
|
|
1641
|
+
key = keys[i];
|
|
1642
|
+
let num = Number(key);
|
|
1643
|
+
pack(isNaN(num) ? key : num);
|
|
1644
|
+
pack(object[key]);
|
|
1645
|
+
}
|
|
1646
|
+
|
|
1647
|
+
} else {
|
|
1648
|
+
for (let i = 0; i < length; i++) {
|
|
1649
|
+
pack(key = keys[i]);
|
|
1650
|
+
pack(object[key]);
|
|
1651
|
+
}
|
|
1642
1652
|
}
|
|
1643
1653
|
} :
|
|
1644
1654
|
(object, safePrototype) => {
|