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