bson 4.3.0 → 4.5.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.
Files changed (62) hide show
  1. package/bower.json +1 -1
  2. package/bson.d.ts +23 -7
  3. package/dist/bson.browser.esm.js +728 -2228
  4. package/dist/bson.browser.esm.js.map +1 -1
  5. package/dist/bson.browser.umd.js +779 -2281
  6. package/dist/bson.browser.umd.js.map +1 -1
  7. package/dist/bson.bundle.js +779 -2281
  8. package/dist/bson.bundle.js.map +1 -1
  9. package/dist/bson.esm.js +718 -2222
  10. package/dist/bson.esm.js.map +1 -1
  11. package/lib/bson.js +1 -1
  12. package/lib/bson.js.map +1 -1
  13. package/lib/db_ref.js +4 -1
  14. package/lib/db_ref.js.map +1 -1
  15. package/lib/decimal128.js +14 -51
  16. package/lib/decimal128.js.map +1 -1
  17. package/lib/ensure_buffer.js +2 -5
  18. package/lib/ensure_buffer.js.map +1 -1
  19. package/lib/extended_json.js +48 -9
  20. package/lib/extended_json.js.map +1 -1
  21. package/lib/long.js +18 -5
  22. package/lib/long.js.map +1 -1
  23. package/lib/map.js +3 -15
  24. package/lib/map.js.map +1 -1
  25. package/lib/objectid.js +9 -17
  26. package/lib/objectid.js.map +1 -1
  27. package/lib/parser/calculate_size.js +5 -6
  28. package/lib/parser/calculate_size.js.map +1 -1
  29. package/lib/parser/deserializer.js +61 -47
  30. package/lib/parser/deserializer.js.map +1 -1
  31. package/lib/parser/serializer.js +14 -13
  32. package/lib/parser/serializer.js.map +1 -1
  33. package/lib/parser/utils.js +21 -15
  34. package/lib/parser/utils.js.map +1 -1
  35. package/lib/regexp.js +1 -3
  36. package/lib/regexp.js.map +1 -1
  37. package/lib/timestamp.js +6 -2
  38. package/lib/timestamp.js.map +1 -1
  39. package/lib/utils/global.js +18 -0
  40. package/lib/utils/global.js.map +1 -0
  41. package/lib/uuid.js +2 -3
  42. package/lib/uuid.js.map +1 -1
  43. package/lib/uuid_utils.js.map +1 -1
  44. package/package.json +10 -8
  45. package/src/bson.ts +1 -1
  46. package/src/db_ref.ts +6 -1
  47. package/src/decimal128.ts +14 -52
  48. package/src/ensure_buffer.ts +7 -7
  49. package/src/extended_json.ts +64 -16
  50. package/src/long.ts +19 -7
  51. package/src/map.ts +5 -25
  52. package/src/objectid.ts +12 -19
  53. package/src/parser/calculate_size.ts +8 -11
  54. package/src/parser/deserializer.ts +68 -51
  55. package/src/parser/serializer.ts +13 -12
  56. package/src/parser/utils.ts +23 -16
  57. package/src/regexp.ts +2 -4
  58. package/src/timestamp.ts +15 -7
  59. package/src/utils/global.ts +22 -0
  60. package/src/uuid.ts +3 -6
  61. package/src/uuid_utils.ts +2 -1
  62. package/HISTORY.md +0 -488
package/bower.json CHANGED
@@ -22,5 +22,5 @@
22
22
  "test",
23
23
  "tools"
24
24
  ],
25
- "version": "4.3.0"
25
+ "version": "4.5.1"
26
26
  }
package/bson.d.ts CHANGED
@@ -260,8 +260,11 @@ export declare interface DBRefLike {
260
260
  export declare class Decimal128 {
261
261
  _bsontype: 'Decimal128';
262
262
  readonly bytes: Buffer;
263
- /** @param bytes - a buffer containing the raw Decimal128 bytes in little endian order */
264
- constructor(bytes: Buffer);
263
+ /**
264
+ * @param bytes - a buffer containing the raw Decimal128 bytes in little endian order,
265
+ * or a string representation as returned by .toString()
266
+ */
267
+ constructor(bytes: Buffer | string);
265
268
  /**
266
269
  * Create a Decimal128 instance from a string representation
267
270
  *
@@ -503,11 +506,17 @@ export declare class Long {
503
506
  /**
504
507
  * Constructs a 64 bit two's-complement integer, given its low and high 32 bit values as *signed* integers.
505
508
  * See the from* functions below for more convenient ways of constructing Longs.
509
+ *
510
+ * Acceptable signatures are:
511
+ * - Long(low, high, unsigned?)
512
+ * - Long(bigint, unsigned?)
513
+ * - Long(string, unsigned?)
514
+ *
506
515
  * @param low - The low (signed) 32 bits of the long
507
516
  * @param high - The high (signed) 32 bits of the long
508
517
  * @param unsigned - Whether unsigned or not, defaults to signed
509
518
  */
510
- constructor(low?: number, high?: number, unsigned?: boolean);
519
+ constructor(low?: number | bigint | string, high?: number | boolean, unsigned?: boolean);
511
520
  static TWO_PWR_24: Long;
512
521
  /** Maximum unsigned value. */
513
522
  static MAX_UNSIGNED_VALUE: Long;
@@ -779,7 +788,7 @@ export declare interface LongExtended {
779
788
  $numberLong: string;
780
789
  }
781
790
  /** @public */
782
- export declare type LongWithoutOverrides = new (low: number | Long, high?: number, unsigned?: boolean) => {
791
+ export declare type LongWithoutOverrides = new (low: unknown, high?: number, unsigned?: boolean) => {
783
792
  [P in Exclude<keyof Long, TimestampOverrides>]: Long[P];
784
793
  };
785
794
  /** @public */
@@ -880,7 +889,7 @@ declare class ObjectId {
880
889
  *
881
890
  * @param id - ObjectId instance to validate.
882
891
  */
883
- static isValid(id: number | string | ObjectId | Buffer | ObjectIdLike): boolean;
892
+ static isValid(id: number | string | ObjectId | Uint8Array | ObjectIdLike): boolean;
884
893
  /* Excluded from this release type: toExtendedJSON */
885
894
  /* Excluded from this release type: fromExtendedJSON */
886
895
  inspect(): string;
@@ -941,12 +950,19 @@ export declare class Timestamp extends LongWithoutOverridesClass {
941
950
  /**
942
951
  * @param low - A 64-bit Long representing the Timestamp.
943
952
  */
944
- constructor(low: Long);
953
+ constructor(long: Long);
954
+ /**
955
+ * @param value - A pair of two values indicating timestamp and increment.
956
+ */
957
+ constructor(value: {
958
+ t: number;
959
+ i: number;
960
+ });
945
961
  /**
946
962
  * @param low - the low (signed) 32 bits of the Timestamp.
947
963
  * @param high - the high (signed) 32 bits of the Timestamp.
964
+ * @deprecated Please use `Timestamp({ t: high, i: low })` or `Timestamp(Long(low, high))` instead.
948
965
  */
949
- constructor(low: Long);
950
966
  constructor(low: number, high: number);
951
967
  toJSON(): {
952
968
  $timestamp: string;