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
@@ -2447,6 +2447,7 @@ var BSON = (function (exports) {
2447
2447
  /**
2448
2448
  * A class representation of the BSON Binary type.
2449
2449
  * @public
2450
+ * @category BSONType
2450
2451
  */
2451
2452
  var Binary = /** @class */ (function () {
2452
2453
  /**
@@ -2677,6 +2678,7 @@ var BSON = (function (exports) {
2677
2678
  /**
2678
2679
  * A class representation of the BSON Code type.
2679
2680
  * @public
2681
+ * @category BSONType
2680
2682
  */
2681
2683
  var Code = /** @class */ (function () {
2682
2684
  /**
@@ -2725,6 +2727,7 @@ var BSON = (function (exports) {
2725
2727
  /**
2726
2728
  * A class representation of the BSON DBRef type.
2727
2729
  * @public
2730
+ * @category BSONType
2728
2731
  */
2729
2732
  var DBRef = /** @class */ (function () {
2730
2733
  /**
@@ -2829,6 +2832,7 @@ var BSON = (function (exports) {
2829
2832
  /**
2830
2833
  * A class representing a 64-bit integer
2831
2834
  * @public
2835
+ * @category BSONType
2832
2836
  * @remarks
2833
2837
  * The internal representation of a long is the two given signed, 32-bit values.
2834
2838
  * We use 32-bit pieces because these are the size of integers on which
@@ -3791,6 +3795,7 @@ var BSON = (function (exports) {
3791
3795
  /**
3792
3796
  * A class representation of the BSON Decimal128 type.
3793
3797
  * @public
3798
+ * @category BSONType
3794
3799
  */
3795
3800
  var Decimal128 = /** @class */ (function () {
3796
3801
  /**
@@ -4362,6 +4367,7 @@ var BSON = (function (exports) {
4362
4367
  /**
4363
4368
  * A class representation of the BSON Double type.
4364
4369
  * @public
4370
+ * @category BSONType
4365
4371
  */
4366
4372
  var Double = /** @class */ (function () {
4367
4373
  /**
@@ -4433,6 +4439,7 @@ var BSON = (function (exports) {
4433
4439
  /**
4434
4440
  * A class representation of a BSON Int32 type.
4435
4441
  * @public
4442
+ * @category BSONType
4436
4443
  */
4437
4444
  var Int32 = /** @class */ (function () {
4438
4445
  /**
@@ -4486,6 +4493,7 @@ var BSON = (function (exports) {
4486
4493
  /**
4487
4494
  * A class representation of the BSON MaxKey type.
4488
4495
  * @public
4496
+ * @category BSONType
4489
4497
  */
4490
4498
  var MaxKey = /** @class */ (function () {
4491
4499
  function MaxKey() {
@@ -4514,6 +4522,7 @@ var BSON = (function (exports) {
4514
4522
  /**
4515
4523
  * A class representation of the BSON MinKey type.
4516
4524
  * @public
4525
+ * @category BSONType
4517
4526
  */
4518
4527
  var MinKey = /** @class */ (function () {
4519
4528
  function MinKey() {
@@ -4547,6 +4556,7 @@ var BSON = (function (exports) {
4547
4556
  /**
4548
4557
  * A class representation of the BSON ObjectId type.
4549
4558
  * @public
4559
+ * @category BSONType
4550
4560
  */
4551
4561
  var ObjectId = /** @class */ (function () {
4552
4562
  /**
@@ -4580,7 +4590,8 @@ var BSON = (function (exports) {
4580
4590
  this[kId] = ObjectId.generate(typeof workingId === 'number' ? workingId : undefined);
4581
4591
  }
4582
4592
  else if (ArrayBuffer.isView(workingId) && workingId.byteLength === 12) {
4583
- this[kId] = ensureBuffer(workingId);
4593
+ // If intstanceof matches we can escape calling ensure buffer in Node.js environments
4594
+ this[kId] = workingId instanceof buffer_1 ? workingId : ensureBuffer(workingId);
4584
4595
  }
4585
4596
  else if (typeof workingId === 'string') {
4586
4597
  if (workingId.length === 12) {
@@ -4596,7 +4607,7 @@ var BSON = (function (exports) {
4596
4607
  this[kId] = buffer_1.from(workingId, 'hex');
4597
4608
  }
4598
4609
  else {
4599
- throw new BSONTypeError('Argument passed in must be a string of 12 bytes or a string of 24 hex characters');
4610
+ throw new BSONTypeError('Argument passed in must be a string of 12 bytes or a string of 24 hex characters or an integer');
4600
4611
  }
4601
4612
  }
4602
4613
  else {
@@ -4713,7 +4724,7 @@ var BSON = (function (exports) {
4713
4724
  return false;
4714
4725
  }
4715
4726
  if (otherId instanceof ObjectId) {
4716
- return this.toString() === otherId.toString();
4727
+ return this[kId][11] === otherId[kId][11] && this[kId].equals(otherId[kId]);
4717
4728
  }
4718
4729
  if (typeof otherId === 'string' &&
4719
4730
  ObjectId.isValid(otherId) &&
@@ -4730,7 +4741,9 @@ var BSON = (function (exports) {
4730
4741
  if (typeof otherId === 'object' &&
4731
4742
  'toHexString' in otherId &&
4732
4743
  typeof otherId.toHexString === 'function') {
4733
- return otherId.toHexString() === this.toHexString();
4744
+ var otherIdString = otherId.toHexString();
4745
+ var thisIdString = this.toHexString().toLowerCase();
4746
+ return typeof otherIdString === 'string' && otherIdString.toLowerCase() === thisIdString;
4734
4747
  }
4735
4748
  return false;
4736
4749
  };
@@ -4832,6 +4845,7 @@ var BSON = (function (exports) {
4832
4845
  /**
4833
4846
  * A class representation of the BSON RegExp type.
4834
4847
  * @public
4848
+ * @category BSONType
4835
4849
  */
4836
4850
  var BSONRegExp = /** @class */ (function () {
4837
4851
  /**
@@ -4897,6 +4911,7 @@ var BSON = (function (exports) {
4897
4911
  /**
4898
4912
  * A class representation of the BSON Symbol type.
4899
4913
  * @public
4914
+ * @category BSONType
4900
4915
  */
4901
4916
  var BSONSymbol = /** @class */ (function () {
4902
4917
  /**
@@ -4939,7 +4954,10 @@ var BSON = (function (exports) {
4939
4954
 
4940
4955
  /** @public */
4941
4956
  var LongWithoutOverridesClass = Long;
4942
- /** @public */
4957
+ /**
4958
+ * @public
4959
+ * @category BSONType
4960
+ * */
4943
4961
  var Timestamp = /** @class */ (function (_super) {
4944
4962
  __extends(Timestamp, _super);
4945
4963
  function Timestamp(low, high) {