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.js
CHANGED
|
@@ -1619,7 +1619,7 @@
|
|
|
1619
1619
|
}
|
|
1620
1620
|
};
|
|
1621
1621
|
|
|
1622
|
-
const writePlainObject = this.variableMapSize ? (object) => {
|
|
1622
|
+
const writePlainObject = (this.variableMapSize || this.coercibleKeyAsNumber) ? (object) => {
|
|
1623
1623
|
// this method is slightly slower, but generates "preferred serialization" (optimally small for smaller objects)
|
|
1624
1624
|
let keys = Object.keys(object);
|
|
1625
1625
|
let length = keys.length;
|
|
@@ -1635,9 +1635,19 @@
|
|
|
1635
1635
|
position += 4;
|
|
1636
1636
|
}
|
|
1637
1637
|
let key;
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1638
|
+
if (this.coercibleKeyAsNumber) {
|
|
1639
|
+
for (let i = 0; i < length; i++) {
|
|
1640
|
+
key = keys[i];
|
|
1641
|
+
let num = Number(key);
|
|
1642
|
+
pack(isNaN(num) ? key : num);
|
|
1643
|
+
pack(object[key]);
|
|
1644
|
+
}
|
|
1645
|
+
|
|
1646
|
+
} else {
|
|
1647
|
+
for (let i = 0; i < length; i++) {
|
|
1648
|
+
pack(key = keys[i]);
|
|
1649
|
+
pack(object[key]);
|
|
1650
|
+
}
|
|
1641
1651
|
}
|
|
1642
1652
|
} :
|
|
1643
1653
|
(object, safePrototype) => {
|