bson 4.6.1 → 4.6.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.
Files changed (51) hide show
  1. package/bower.json +1 -1
  2. package/bson-ts34.d.ts +1133 -0
  3. package/bson.d.ts +1228 -1118
  4. package/dist/bson.browser.esm.js +23 -5
  5. package/dist/bson.browser.esm.js.map +1 -1
  6. package/dist/bson.browser.umd.js +23 -5
  7. package/dist/bson.browser.umd.js.map +1 -1
  8. package/dist/bson.bundle.js +23 -5
  9. package/dist/bson.bundle.js.map +1 -1
  10. package/dist/bson.esm.js +23 -5
  11. package/dist/bson.esm.js.map +1 -1
  12. package/lib/binary.js +1 -0
  13. package/lib/binary.js.map +1 -1
  14. package/lib/code.js +1 -0
  15. package/lib/code.js.map +1 -1
  16. package/lib/db_ref.js +1 -0
  17. package/lib/db_ref.js.map +1 -1
  18. package/lib/decimal128.js +1 -0
  19. package/lib/decimal128.js.map +1 -1
  20. package/lib/double.js +1 -0
  21. package/lib/double.js.map +1 -1
  22. package/lib/int_32.js +1 -0
  23. package/lib/int_32.js.map +1 -1
  24. package/lib/long.js +1 -0
  25. package/lib/long.js.map +1 -1
  26. package/lib/max_key.js +1 -0
  27. package/lib/max_key.js.map +1 -1
  28. package/lib/min_key.js +1 -0
  29. package/lib/min_key.js.map +1 -1
  30. package/lib/objectid.js +8 -4
  31. package/lib/objectid.js.map +1 -1
  32. package/lib/regexp.js +1 -0
  33. package/lib/regexp.js.map +1 -1
  34. package/lib/symbol.js +1 -0
  35. package/lib/symbol.js.map +1 -1
  36. package/lib/timestamp.js +4 -1
  37. package/lib/timestamp.js.map +1 -1
  38. package/package.json +11 -3
  39. package/src/binary.ts +1 -0
  40. package/src/code.ts +1 -0
  41. package/src/db_ref.ts +1 -0
  42. package/src/decimal128.ts +1 -0
  43. package/src/double.ts +1 -0
  44. package/src/int_32.ts +1 -0
  45. package/src/long.ts +1 -0
  46. package/src/max_key.ts +1 -0
  47. package/src/min_key.ts +1 -0
  48. package/src/objectid.ts +9 -5
  49. package/src/regexp.ts +1 -0
  50. package/src/symbol.ts +1 -0
  51. package/src/timestamp.ts +4 -1
@@ -2450,6 +2450,7 @@
2450
2450
  /**
2451
2451
  * A class representation of the BSON Binary type.
2452
2452
  * @public
2453
+ * @category BSONType
2453
2454
  */
2454
2455
  var Binary = /** @class */ (function () {
2455
2456
  /**
@@ -2680,6 +2681,7 @@
2680
2681
  /**
2681
2682
  * A class representation of the BSON Code type.
2682
2683
  * @public
2684
+ * @category BSONType
2683
2685
  */
2684
2686
  var Code = /** @class */ (function () {
2685
2687
  /**
@@ -2728,6 +2730,7 @@
2728
2730
  /**
2729
2731
  * A class representation of the BSON DBRef type.
2730
2732
  * @public
2733
+ * @category BSONType
2731
2734
  */
2732
2735
  var DBRef = /** @class */ (function () {
2733
2736
  /**
@@ -2832,6 +2835,7 @@
2832
2835
  /**
2833
2836
  * A class representing a 64-bit integer
2834
2837
  * @public
2838
+ * @category BSONType
2835
2839
  * @remarks
2836
2840
  * The internal representation of a long is the two given signed, 32-bit values.
2837
2841
  * We use 32-bit pieces because these are the size of integers on which
@@ -3794,6 +3798,7 @@
3794
3798
  /**
3795
3799
  * A class representation of the BSON Decimal128 type.
3796
3800
  * @public
3801
+ * @category BSONType
3797
3802
  */
3798
3803
  var Decimal128 = /** @class */ (function () {
3799
3804
  /**
@@ -4365,6 +4370,7 @@
4365
4370
  /**
4366
4371
  * A class representation of the BSON Double type.
4367
4372
  * @public
4373
+ * @category BSONType
4368
4374
  */
4369
4375
  var Double = /** @class */ (function () {
4370
4376
  /**
@@ -4436,6 +4442,7 @@
4436
4442
  /**
4437
4443
  * A class representation of a BSON Int32 type.
4438
4444
  * @public
4445
+ * @category BSONType
4439
4446
  */
4440
4447
  var Int32 = /** @class */ (function () {
4441
4448
  /**
@@ -4489,6 +4496,7 @@
4489
4496
  /**
4490
4497
  * A class representation of the BSON MaxKey type.
4491
4498
  * @public
4499
+ * @category BSONType
4492
4500
  */
4493
4501
  var MaxKey = /** @class */ (function () {
4494
4502
  function MaxKey() {
@@ -4517,6 +4525,7 @@
4517
4525
  /**
4518
4526
  * A class representation of the BSON MinKey type.
4519
4527
  * @public
4528
+ * @category BSONType
4520
4529
  */
4521
4530
  var MinKey = /** @class */ (function () {
4522
4531
  function MinKey() {
@@ -4550,6 +4559,7 @@
4550
4559
  /**
4551
4560
  * A class representation of the BSON ObjectId type.
4552
4561
  * @public
4562
+ * @category BSONType
4553
4563
  */
4554
4564
  var ObjectId = /** @class */ (function () {
4555
4565
  /**
@@ -4583,7 +4593,8 @@
4583
4593
  this[kId] = ObjectId.generate(typeof workingId === 'number' ? workingId : undefined);
4584
4594
  }
4585
4595
  else if (ArrayBuffer.isView(workingId) && workingId.byteLength === 12) {
4586
- this[kId] = ensureBuffer(workingId);
4596
+ // If intstanceof matches we can escape calling ensure buffer in Node.js environments
4597
+ this[kId] = workingId instanceof buffer_1 ? workingId : ensureBuffer(workingId);
4587
4598
  }
4588
4599
  else if (typeof workingId === 'string') {
4589
4600
  if (workingId.length === 12) {
@@ -4599,7 +4610,7 @@
4599
4610
  this[kId] = buffer_1.from(workingId, 'hex');
4600
4611
  }
4601
4612
  else {
4602
- throw new BSONTypeError('Argument passed in must be a string of 12 bytes or a string of 24 hex characters');
4613
+ throw new BSONTypeError('Argument passed in must be a string of 12 bytes or a string of 24 hex characters or an integer');
4603
4614
  }
4604
4615
  }
4605
4616
  else {
@@ -4716,7 +4727,7 @@
4716
4727
  return false;
4717
4728
  }
4718
4729
  if (otherId instanceof ObjectId) {
4719
- return this.toString() === otherId.toString();
4730
+ return this[kId][11] === otherId[kId][11] && this[kId].equals(otherId[kId]);
4720
4731
  }
4721
4732
  if (typeof otherId === 'string' &&
4722
4733
  ObjectId.isValid(otherId) &&
@@ -4733,7 +4744,9 @@
4733
4744
  if (typeof otherId === 'object' &&
4734
4745
  'toHexString' in otherId &&
4735
4746
  typeof otherId.toHexString === 'function') {
4736
- return otherId.toHexString() === this.toHexString();
4747
+ var otherIdString = otherId.toHexString();
4748
+ var thisIdString = this.toHexString().toLowerCase();
4749
+ return typeof otherIdString === 'string' && otherIdString.toLowerCase() === thisIdString;
4737
4750
  }
4738
4751
  return false;
4739
4752
  };
@@ -4835,6 +4848,7 @@
4835
4848
  /**
4836
4849
  * A class representation of the BSON RegExp type.
4837
4850
  * @public
4851
+ * @category BSONType
4838
4852
  */
4839
4853
  var BSONRegExp = /** @class */ (function () {
4840
4854
  /**
@@ -4900,6 +4914,7 @@
4900
4914
  /**
4901
4915
  * A class representation of the BSON Symbol type.
4902
4916
  * @public
4917
+ * @category BSONType
4903
4918
  */
4904
4919
  var BSONSymbol = /** @class */ (function () {
4905
4920
  /**
@@ -4942,7 +4957,10 @@
4942
4957
 
4943
4958
  /** @public */
4944
4959
  var LongWithoutOverridesClass = Long;
4945
- /** @public */
4960
+ /**
4961
+ * @public
4962
+ * @category BSONType
4963
+ * */
4946
4964
  var Timestamp = /** @class */ (function (_super) {
4947
4965
  __extends(Timestamp, _super);
4948
4966
  function Timestamp(low, high) {