bson 4.4.0 → 4.4.1

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/HISTORY.md CHANGED
@@ -2,6 +2,16 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ### [4.4.1](https://github.com/mongodb/js-bson/compare/v4.4.0...v4.4.1) (2021-07-06)
6
+
7
+
8
+ ### Bug Fixes
9
+
10
+ * **NODE-3247:** DBRef special handling ([#443](https://github.com/mongodb/js-bson/issues/443)) ([f5d984d](https://github.com/mongodb/js-bson/commit/f5d984d88b2e20310ec5cc3a39b91b0fd1e0b3c9))
11
+ * **NODE-3282:** BSONRegExp options not alphabetized ([#441](https://github.com/mongodb/js-bson/issues/441)) ([18c3512](https://github.com/mongodb/js-bson/commit/18c3512befe54908e4b816056dbde0d1b998d81b))
12
+ * **NODE-3376:** use standard JS methods for copying Buffers ([#444](https://github.com/mongodb/js-bson/issues/444)) ([804050d](https://github.com/mongodb/js-bson/commit/804050d40b03a02116995e63671e05ffa033dc45))
13
+ * **NODE-3390:** serialize non-finite doubles correctly in EJSON ([#445](https://github.com/mongodb/js-bson/issues/445)) ([7eb7998](https://github.com/mongodb/js-bson/commit/7eb79981e16d73a391c567b7f9748943997a424d))
14
+
5
15
  ## [4.4.0](https://github.com/mongodb/js-bson/compare/v4.3.0...v4.4.0) (2021-05-18)
6
16
 
7
17
 
package/bower.json CHANGED
@@ -22,5 +22,5 @@
22
22
  "test",
23
23
  "tools"
24
24
  ],
25
- "version": "4.4.0"
25
+ "version": "4.4.1"
26
26
  }
@@ -2039,6 +2039,14 @@ buffer.kMaxLength;
2039
2039
 
2040
2040
  var require$$0 = {};
2041
2041
 
2042
+ // shim for using process in browser
2043
+
2044
+ var performance = global.performance || {};
2045
+
2046
+ performance.now || performance.mozNow || performance.msNow || performance.oNow || performance.webkitNow || function () {
2047
+ return new Date().getTime();
2048
+ }; // generate timestamp or delta
2049
+
2042
2050
  var inherits;
2043
2051
 
2044
2052
  if (typeof Object.create === 'function') {
@@ -2701,7 +2709,7 @@ function deprecate(fn, message) {
2701
2709
  return deprecated;
2702
2710
  }
2703
2711
  exports.deprecate = deprecate;
2704
- //# sourceMappingURL=utils.js.map
2712
+
2705
2713
  });
2706
2714
 
2707
2715
  unwrapExports(utils);
@@ -2741,7 +2749,7 @@ function ensureBuffer(potentialBuffer) {
2741
2749
  throw new TypeError('Must use either Buffer or TypedArray');
2742
2750
  }
2743
2751
  exports.ensureBuffer = ensureBuffer;
2744
- //# sourceMappingURL=ensure_buffer.js.map
2752
+
2745
2753
  });
2746
2754
 
2747
2755
  unwrapExports(ensure_buffer);
@@ -2780,7 +2788,7 @@ var bufferToUuidHexString = function (buffer, includeDashes) {
2780
2788
  : buffer.toString('hex');
2781
2789
  };
2782
2790
  exports.bufferToUuidHexString = bufferToUuidHexString;
2783
- //# sourceMappingURL=uuid_utils.js.map
2791
+
2784
2792
  });
2785
2793
 
2786
2794
  unwrapExports(uuid_utils);
@@ -2966,7 +2974,7 @@ var UUID = /** @class */ (function () {
2966
2974
  }());
2967
2975
  exports.UUID = UUID;
2968
2976
  Object.defineProperty(UUID.prototype, '_bsontype', { value: 'UUID' });
2969
- //# sourceMappingURL=uuid.js.map
2977
+
2970
2978
  });
2971
2979
 
2972
2980
  unwrapExports(uuid);
@@ -3208,7 +3216,7 @@ var Binary = /** @class */ (function () {
3208
3216
  }());
3209
3217
  exports.Binary = Binary;
3210
3218
  Object.defineProperty(Binary.prototype, '_bsontype', { value: 'Binary' });
3211
- //# sourceMappingURL=binary.js.map
3219
+
3212
3220
  });
3213
3221
 
3214
3222
  unwrapExports(binary);
@@ -3259,7 +3267,7 @@ var Code = /** @class */ (function () {
3259
3267
  }());
3260
3268
  exports.Code = Code;
3261
3269
  Object.defineProperty(Code.prototype, '_bsontype', { value: 'Code' });
3262
- //# sourceMappingURL=code.js.map
3270
+
3263
3271
  });
3264
3272
 
3265
3273
  unwrapExports(code);
@@ -3271,7 +3279,10 @@ exports.DBRef = exports.isDBRefLike = void 0;
3271
3279
 
3272
3280
  /** @internal */
3273
3281
  function isDBRefLike(value) {
3274
- return utils.isObjectLike(value) && value['$id'] != null && value['$ref'] != null;
3282
+ return (utils.isObjectLike(value) &&
3283
+ value.$id != null &&
3284
+ typeof value.$ref === 'string' &&
3285
+ (value.$db == null || typeof value.$db === 'string'));
3275
3286
  }
3276
3287
  exports.isDBRefLike = isDBRefLike;
3277
3288
  /**
@@ -3358,7 +3369,7 @@ var DBRef = /** @class */ (function () {
3358
3369
  }());
3359
3370
  exports.DBRef = DBRef;
3360
3371
  Object.defineProperty(DBRef.prototype, '_bsontype', { value: 'DBRef' });
3361
- //# sourceMappingURL=db_ref.js.map
3372
+
3362
3373
  });
3363
3374
 
3364
3375
  unwrapExports(db_ref);
@@ -4263,7 +4274,7 @@ var Long = /** @class */ (function () {
4263
4274
  exports.Long = Long;
4264
4275
  Object.defineProperty(Long.prototype, '__isLong__', { value: true });
4265
4276
  Object.defineProperty(Long.prototype, '_bsontype', { value: 'Long' });
4266
- //# sourceMappingURL=long.js.map
4277
+
4267
4278
  });
4268
4279
 
4269
4280
  unwrapExports(long_1);
@@ -4973,7 +4984,7 @@ var Decimal128 = /** @class */ (function () {
4973
4984
  }());
4974
4985
  exports.Decimal128 = Decimal128;
4975
4986
  Object.defineProperty(Decimal128.prototype, '_bsontype', { value: 'Decimal128' });
4976
- //# sourceMappingURL=decimal128.js.map
4987
+
4977
4988
  });
4978
4989
 
4979
4990
  unwrapExports(decimal128);
@@ -5051,7 +5062,7 @@ var Double = /** @class */ (function () {
5051
5062
  }());
5052
5063
  exports.Double = Double;
5053
5064
  Object.defineProperty(Double.prototype, '_bsontype', { value: 'Double' });
5054
- //# sourceMappingURL=double.js.map
5065
+
5055
5066
  });
5056
5067
 
5057
5068
  unwrapExports(double_1);
@@ -5111,7 +5122,7 @@ var Int32 = /** @class */ (function () {
5111
5122
  }());
5112
5123
  exports.Int32 = Int32;
5113
5124
  Object.defineProperty(Int32.prototype, '_bsontype', { value: 'Int32' });
5114
- //# sourceMappingURL=int_32.js.map
5125
+
5115
5126
  });
5116
5127
 
5117
5128
  unwrapExports(int_32);
@@ -5148,7 +5159,7 @@ var MaxKey = /** @class */ (function () {
5148
5159
  }());
5149
5160
  exports.MaxKey = MaxKey;
5150
5161
  Object.defineProperty(MaxKey.prototype, '_bsontype', { value: 'MaxKey' });
5151
- //# sourceMappingURL=max_key.js.map
5162
+
5152
5163
  });
5153
5164
 
5154
5165
  unwrapExports(max_key);
@@ -5185,7 +5196,7 @@ var MinKey = /** @class */ (function () {
5185
5196
  }());
5186
5197
  exports.MinKey = MinKey;
5187
5198
  Object.defineProperty(MinKey.prototype, '_bsontype', { value: 'MinKey' });
5188
- //# sourceMappingURL=min_key.js.map
5199
+
5189
5200
  });
5190
5201
 
5191
5202
  unwrapExports(min_key);
@@ -5494,7 +5505,7 @@ Object.defineProperty(ObjectId, 'get_inc', {
5494
5505
  value: utils.deprecate(function () { return ObjectId.getInc(); }, 'Please use the static `ObjectId.getInc()` instead')
5495
5506
  });
5496
5507
  Object.defineProperty(ObjectId.prototype, '_bsontype', { value: 'ObjectID' });
5497
- //# sourceMappingURL=objectid.js.map
5508
+
5498
5509
  });
5499
5510
 
5500
5511
  unwrapExports(objectid);
@@ -5519,9 +5530,7 @@ var BSONRegExp = /** @class */ (function () {
5519
5530
  if (!(this instanceof BSONRegExp))
5520
5531
  return new BSONRegExp(pattern, options);
5521
5532
  this.pattern = pattern;
5522
- this.options = options !== null && options !== void 0 ? options : '';
5523
- // Execute
5524
- alphabetize(this.options);
5533
+ this.options = alphabetize(options !== null && options !== void 0 ? options : '');
5525
5534
  // Validate options
5526
5535
  for (var i = 0; i < this.options.length; i++) {
5527
5536
  if (!(this.options[i] === 'i' ||
@@ -5567,7 +5576,7 @@ var BSONRegExp = /** @class */ (function () {
5567
5576
  }());
5568
5577
  exports.BSONRegExp = BSONRegExp;
5569
5578
  Object.defineProperty(BSONRegExp.prototype, '_bsontype', { value: 'BSONRegExp' });
5570
- //# sourceMappingURL=regexp.js.map
5579
+
5571
5580
  });
5572
5581
 
5573
5582
  unwrapExports(regexp);
@@ -5621,7 +5630,7 @@ var BSONSymbol = /** @class */ (function () {
5621
5630
  }());
5622
5631
  exports.BSONSymbol = BSONSymbol;
5623
5632
  Object.defineProperty(BSONSymbol.prototype, '_bsontype', { value: 'Symbol' });
5624
- //# sourceMappingURL=symbol.js.map
5633
+
5625
5634
  });
5626
5635
 
5627
5636
  unwrapExports(symbol);
@@ -6157,7 +6166,7 @@ var Timestamp = /** @class */ (function (_super) {
6157
6166
  return Timestamp;
6158
6167
  }(exports.LongWithoutOverridesClass));
6159
6168
  exports.Timestamp = Timestamp;
6160
- //# sourceMappingURL=timestamp.js.map
6169
+
6161
6170
  });
6162
6171
 
6163
6172
  unwrapExports(timestamp);
@@ -6264,7 +6273,7 @@ function deserializeValue(value, options) {
6264
6273
  }
6265
6274
  return code.Code.fromExtendedJSON(value);
6266
6275
  }
6267
- if (value.$ref != null || value.$dbPointer != null) {
6276
+ if (db_ref.isDBRefLike(value) || value.$dbPointer) {
6268
6277
  var v = value.$ref ? value : value.$dbPointer;
6269
6278
  // we run into this in a "degenerate EJSON" case (with $id and $ref order flipped)
6270
6279
  // because of the order JSON.parse goes through the document
@@ -6341,7 +6350,7 @@ function serializeValue(value, options) {
6341
6350
  ? { $date: getISOString(value) }
6342
6351
  : { $date: { $numberLong: value.getTime().toString() } };
6343
6352
  }
6344
- if (typeof value === 'number' && !options.relaxed) {
6353
+ if (typeof value === 'number' && (!options.relaxed || !isFinite(value))) {
6345
6354
  // it's an integer
6346
6355
  if (Math.floor(value) === value) {
6347
6356
  var int32Range = value >= BSON_INT32_MIN && value <= BSON_INT32_MAX, int64Range = value >= BSON_INT64_MIN && value <= BSON_INT64_MAX;
@@ -6427,7 +6436,7 @@ function serializeDocument(doc, options) {
6427
6436
  outDoc = new code.Code(outDoc.code, serializeValue(outDoc.scope, options));
6428
6437
  }
6429
6438
  else if (bsontype === 'DBRef' && outDoc.oid) {
6430
- outDoc = new db_ref.DBRef(outDoc.collection, serializeValue(outDoc.oid, options), outDoc.db, outDoc.fields);
6439
+ outDoc = new db_ref.DBRef(serializeValue(outDoc.collection, options), serializeValue(outDoc.oid, options), serializeValue(outDoc.db, options), serializeValue(outDoc.fields, options));
6431
6440
  }
6432
6441
  return outDoc.toExtendedJSON(options);
6433
6442
  }
@@ -6527,7 +6536,7 @@ function serializeDocument(doc, options) {
6527
6536
  }
6528
6537
  EJSON.deserialize = deserialize;
6529
6538
  })(exports.EJSON || (exports.EJSON = {}));
6530
- //# sourceMappingURL=extended_json.js.map
6539
+
6531
6540
  });
6532
6541
 
6533
6542
  unwrapExports(extended_json);
@@ -6668,7 +6677,7 @@ else {
6668
6677
  return Map;
6669
6678
  }());
6670
6679
  }
6671
- //# sourceMappingURL=map.js.map
6680
+
6672
6681
  });
6673
6682
 
6674
6683
  unwrapExports(map);
@@ -6751,7 +6760,7 @@ exports.BSON_BINARY_SUBTYPE_UUID_NEW = 4;
6751
6760
  exports.BSON_BINARY_SUBTYPE_MD5 = 5;
6752
6761
  /** Binary User Defined Type @internal */
6753
6762
  exports.BSON_BINARY_SUBTYPE_USER_DEFINED = 128;
6754
- //# sourceMappingURL=constants.js.map
6763
+
6755
6764
  });
6756
6765
 
6757
6766
  unwrapExports(constants);
@@ -6982,7 +6991,7 @@ value, serializeFunctions, isArray, ignoreUndefined) {
6982
6991
  }
6983
6992
  return 0;
6984
6993
  }
6985
- //# sourceMappingURL=calculate_size.js.map
6994
+
6986
6995
  });
6987
6996
 
6988
6997
  unwrapExports(calculate_size);
@@ -7034,7 +7043,7 @@ function validateUtf8(bytes, start, end) {
7034
7043
  return !continuation;
7035
7044
  }
7036
7045
  exports.validateUtf8 = validateUtf8;
7037
- //# sourceMappingURL=validate_utf8.js.map
7046
+
7038
7047
  });
7039
7048
 
7040
7049
  unwrapExports(validate_utf8);
@@ -7614,7 +7623,7 @@ function isolateEval(functionString, functionCache, object) {
7614
7623
  // Set the object
7615
7624
  return functionCache[functionString].bind(object);
7616
7625
  }
7617
- //# sourceMappingURL=deserializer.js.map
7626
+
7618
7627
  });
7619
7628
 
7620
7629
  unwrapExports(deserializer);
@@ -7756,7 +7765,7 @@ function writeIEEE754(buffer, value, offset, endian, mLen, nBytes) {
7756
7765
  buffer[offset + i - d] |= s * 128;
7757
7766
  }
7758
7767
  exports.writeIEEE754 = writeIEEE754;
7759
- //# sourceMappingURL=float_parser.js.map
7768
+
7760
7769
  });
7761
7770
 
7762
7771
  unwrapExports(float_parser);
@@ -7983,8 +7992,10 @@ function serializeObjectId(buffer, key, value, index, isArray) {
7983
7992
  if (typeof value.id === 'string') {
7984
7993
  buffer.write(value.id, index, undefined, 'binary');
7985
7994
  }
7986
- else if (value.id && value.id.copy) {
7987
- value.id.copy(buffer, index, 0, 12);
7995
+ else if (utils.isUint8Array(value.id)) {
7996
+ // Use the standard JS methods here because buffer.copy() is buggy with the
7997
+ // browser polyfill
7998
+ buffer.set(value.id.subarray(0, 12), index);
7988
7999
  }
7989
8000
  else {
7990
8001
  throw new TypeError('object [' + JSON.stringify(value) + '] is not a valid ObjectId');
@@ -8054,7 +8065,9 @@ function serializeDecimal128(buffer, key, value, index, isArray) {
8054
8065
  index = index + numberOfWrittenBytes;
8055
8066
  buffer[index++] = 0;
8056
8067
  // Write the data from the value
8057
- value.bytes.copy(buffer, index, 0, 16);
8068
+ // Prefer the standard JS methods because their typechecking is not buggy,
8069
+ // unlike the `buffer` polyfill's.
8070
+ buffer.set(value.bytes.subarray(0, 16), index);
8058
8071
  return index + 16;
8059
8072
  }
8060
8073
  function serializeLong(buffer, key, value, index, isArray) {
@@ -8624,7 +8637,7 @@ function serializeInto(buffer, object, checkKeys, startingIndex, depth, serializ
8624
8637
  return index;
8625
8638
  }
8626
8639
  exports.serializeInto = serializeInto;
8627
- //# sourceMappingURL=serializer.js.map
8640
+
8628
8641
  });
8629
8642
 
8630
8643
  unwrapExports(serializer);
@@ -8873,7 +8886,7 @@ var BSON = {
8873
8886
  deserializeStream: deserializeStream
8874
8887
  };
8875
8888
  exports.default = BSON;
8876
- //# sourceMappingURL=bson.js.map
8889
+
8877
8890
  });
8878
8891
 
8879
8892
  var bson$1 = unwrapExports(bson);