bson 5.0.1 → 5.1.0

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/lib/bson.cjs CHANGED
@@ -3787,6 +3787,16 @@ function getISOString(date) {
3787
3787
  return date.getUTCMilliseconds() !== 0 ? isoStr : isoStr.slice(0, -5) + 'Z';
3788
3788
  }
3789
3789
  function serializeValue(value, options) {
3790
+ if (value instanceof Map || isMap(value)) {
3791
+ const obj = Object.create(null);
3792
+ for (const [k, v] of value) {
3793
+ if (typeof k !== 'string') {
3794
+ throw new BSONError('Can only serialize maps with string keys');
3795
+ }
3796
+ obj[k] = v;
3797
+ }
3798
+ return serializeValue(obj, options);
3799
+ }
3790
3800
  if ((typeof value === 'object' || typeof value === 'function') && value !== null) {
3791
3801
  const index = options.seenObjects.findIndex(entry => entry.obj === value);
3792
3802
  if (index !== -1) {