cbor-x 1.5.3 → 1.5.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 +8 -1
- 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 +8 -1
- 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 +8 -1
- package/dist/node.cjs.map +1 -1
- package/encode.js +8 -1
- package/index.d.ts +1 -0
- package/package.json +1 -1
package/dist/node.cjs
CHANGED
|
@@ -1696,6 +1696,13 @@ class Encoder extends Decoder {
|
|
|
1696
1696
|
error.iteratorNotHandled = true;
|
|
1697
1697
|
throw error;
|
|
1698
1698
|
}
|
|
1699
|
+
if (this.useToJSON && value.toJSON) {
|
|
1700
|
+
const json = value.toJSON();
|
|
1701
|
+
// if for some reason value.toJSON returns itself it'll loop forever
|
|
1702
|
+
if (json !== value)
|
|
1703
|
+
return encode(json)
|
|
1704
|
+
}
|
|
1705
|
+
|
|
1699
1706
|
// no extension found, write as object
|
|
1700
1707
|
writeObject(value, !value.hasOwnProperty); // if it doesn't have hasOwnProperty, don't do hasOwnProperty checks
|
|
1701
1708
|
}
|
|
@@ -1749,7 +1756,7 @@ class Encoder extends Decoder {
|
|
|
1749
1756
|
}
|
|
1750
1757
|
if (encoder.keyMap) {
|
|
1751
1758
|
for (let i = 0; i < length; i++) {
|
|
1752
|
-
encode(encodeKey(keys[i]));
|
|
1759
|
+
encode(encoder.encodeKey(keys[i]));
|
|
1753
1760
|
encode(vals[i]);
|
|
1754
1761
|
}
|
|
1755
1762
|
} else {
|