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.
@@ -1654,6 +1654,13 @@
1654
1654
  error.iteratorNotHandled = true;
1655
1655
  throw error;
1656
1656
  }
1657
+ if (this.useToJSON && value.toJSON) {
1658
+ const json = value.toJSON();
1659
+ // if for some reason value.toJSON returns itself it'll loop forever
1660
+ if (json !== value)
1661
+ return encode(json)
1662
+ }
1663
+
1657
1664
  // no extension found, write as object
1658
1665
  writeObject(value, !value.hasOwnProperty); // if it doesn't have hasOwnProperty, don't do hasOwnProperty checks
1659
1666
  }
@@ -1707,7 +1714,7 @@
1707
1714
  }
1708
1715
  if (encoder.keyMap) {
1709
1716
  for (let i = 0; i < length; i++) {
1710
- encode(encodeKey(keys[i]));
1717
+ encode(encoder.encodeKey(keys[i]));
1711
1718
  encode(vals[i]);
1712
1719
  }
1713
1720
  } else {