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
package/package.json CHANGED
@@ -11,11 +11,19 @@
11
11
  "src",
12
12
  "dist",
13
13
  "bson.d.ts",
14
+ "bson-ts34.d.ts",
14
15
  "etc/prepare.js",
15
16
  "bower.json"
16
17
  ],
17
18
  "types": "bson.d.ts",
18
- "version": "4.6.1",
19
+ "typesVersions": {
20
+ "<=4.0.2": {
21
+ "bson.d.ts": [
22
+ "bson.ts34.d.ts"
23
+ ]
24
+ }
25
+ },
26
+ "version": "4.6.4",
19
27
  "author": {
20
28
  "name": "The MongoDB NodeJS Team",
21
29
  "email": "dbx-node@mongodb.com"
@@ -41,7 +49,7 @@
41
49
  "array-includes": "^3.1.3",
42
50
  "benchmark": "^2.1.4",
43
51
  "chai": "^4.2.0",
44
- "downlevel-dts": "^0.7.0",
52
+ "downlevel-dts": "^0.9.0",
45
53
  "eslint": "^7.7.0",
46
54
  "eslint-config-prettier": "^6.11.0",
47
55
  "eslint-plugin-prettier": "^3.1.4",
@@ -99,7 +107,7 @@
99
107
  "test-tsd": "npm run build:dts && tsd",
100
108
  "test-browser": "node --max-old-space-size=4096 ./node_modules/.bin/karma start karma.conf.js",
101
109
  "build:ts": "tsc",
102
- "build:dts": "npm run build:ts && api-extractor run --typescript-compiler-folder node_modules/typescript --local && rimraf 'lib/**/*.d.ts*' && downlevel-dts bson.d.ts bson.d.ts",
110
+ "build:dts": "npm run build:ts && api-extractor run --typescript-compiler-folder node_modules/typescript --local && rimraf 'lib/**/*.d.ts*' && downlevel-dts bson.d.ts bson-ts34.d.ts",
103
111
  "build:bundle": "rollup -c rollup.config.js",
104
112
  "build": "npm run build:dts && npm run build:bundle",
105
113
  "lint": "eslint -v && eslint --ext '.js,.ts' --max-warnings=0 src test && tsc -v && tsc --noEmit && npm run test-tsd",
package/src/binary.ts CHANGED
@@ -25,6 +25,7 @@ export interface BinaryExtended {
25
25
  /**
26
26
  * A class representation of the BSON Binary type.
27
27
  * @public
28
+ * @category BSONType
28
29
  */
29
30
  export class Binary {
30
31
  _bsontype!: 'Binary';
package/src/code.ts CHANGED
@@ -9,6 +9,7 @@ export interface CodeExtended {
9
9
  /**
10
10
  * A class representation of the BSON Code type.
11
11
  * @public
12
+ * @category BSONType
12
13
  */
13
14
  export class Code {
14
15
  _bsontype!: 'Code';
package/src/db_ref.ts CHANGED
@@ -23,6 +23,7 @@ export function isDBRefLike(value: unknown): value is DBRefLike {
23
23
  /**
24
24
  * A class representation of the BSON DBRef type.
25
25
  * @public
26
+ * @category BSONType
26
27
  */
27
28
  export class DBRef {
28
29
  _bsontype!: 'DBRef';
package/src/decimal128.ts CHANGED
@@ -118,6 +118,7 @@ export interface Decimal128Extended {
118
118
  /**
119
119
  * A class representation of the BSON Decimal128 type.
120
120
  * @public
121
+ * @category BSONType
121
122
  */
122
123
  export class Decimal128 {
123
124
  _bsontype!: 'Decimal128';
package/src/double.ts CHANGED
@@ -8,6 +8,7 @@ export interface DoubleExtended {
8
8
  /**
9
9
  * A class representation of the BSON Double type.
10
10
  * @public
11
+ * @category BSONType
11
12
  */
12
13
  export class Double {
13
14
  _bsontype!: 'Double';
package/src/int_32.ts CHANGED
@@ -8,6 +8,7 @@ export interface Int32Extended {
8
8
  /**
9
9
  * A class representation of a BSON Int32 type.
10
10
  * @public
11
+ * @category BSONType
11
12
  */
12
13
  export class Int32 {
13
14
  _bsontype!: 'Int32';
package/src/long.ts CHANGED
@@ -58,6 +58,7 @@ export interface LongExtended {
58
58
  /**
59
59
  * A class representing a 64-bit integer
60
60
  * @public
61
+ * @category BSONType
61
62
  * @remarks
62
63
  * The internal representation of a long is the two given signed, 32-bit values.
63
64
  * We use 32-bit pieces because these are the size of integers on which
package/src/max_key.ts CHANGED
@@ -6,6 +6,7 @@ export interface MaxKeyExtended {
6
6
  /**
7
7
  * A class representation of the BSON MaxKey type.
8
8
  * @public
9
+ * @category BSONType
9
10
  */
10
11
  export class MaxKey {
11
12
  _bsontype!: 'MaxKey';
package/src/min_key.ts CHANGED
@@ -6,6 +6,7 @@ export interface MinKeyExtended {
6
6
  /**
7
7
  * A class representation of the BSON MinKey type.
8
8
  * @public
9
+ * @category BSONType
9
10
  */
10
11
  export class MinKey {
11
12
  _bsontype!: 'MinKey';
package/src/objectid.ts CHANGED
@@ -26,9 +26,10 @@ const kId = Symbol('id');
26
26
  /**
27
27
  * A class representation of the BSON ObjectId type.
28
28
  * @public
29
+ * @category BSONType
29
30
  */
30
31
  export class ObjectId {
31
- _bsontype!: 'ObjectId';
32
+ _bsontype!: 'ObjectID';
32
33
 
33
34
  /** @internal */
34
35
  static index = Math.floor(Math.random() * 0xffffff);
@@ -71,7 +72,8 @@ export class ObjectId {
71
72
  // Generate a new id
72
73
  this[kId] = ObjectId.generate(typeof workingId === 'number' ? workingId : undefined);
73
74
  } else if (ArrayBuffer.isView(workingId) && workingId.byteLength === 12) {
74
- this[kId] = ensureBuffer(workingId);
75
+ // If intstanceof matches we can escape calling ensure buffer in Node.js environments
76
+ this[kId] = workingId instanceof Buffer ? workingId : ensureBuffer(workingId);
75
77
  } else if (typeof workingId === 'string') {
76
78
  if (workingId.length === 12) {
77
79
  const bytes = Buffer.from(workingId);
@@ -84,7 +86,7 @@ export class ObjectId {
84
86
  this[kId] = Buffer.from(workingId, 'hex');
85
87
  } else {
86
88
  throw new BSONTypeError(
87
- 'Argument passed in must be a string of 12 bytes or a string of 24 hex characters'
89
+ 'Argument passed in must be a string of 12 bytes or a string of 24 hex characters or an integer'
88
90
  );
89
91
  }
90
92
  } else {
@@ -212,7 +214,7 @@ export class ObjectId {
212
214
  }
213
215
 
214
216
  if (otherId instanceof ObjectId) {
215
- return this.toString() === otherId.toString();
217
+ return this[kId][11] === otherId[kId][11] && this[kId].equals(otherId[kId]);
216
218
  }
217
219
 
218
220
  if (
@@ -237,7 +239,9 @@ export class ObjectId {
237
239
  'toHexString' in otherId &&
238
240
  typeof otherId.toHexString === 'function'
239
241
  ) {
240
- return otherId.toHexString() === this.toHexString();
242
+ const otherIdString = otherId.toHexString();
243
+ const thisIdString = this.toHexString().toLowerCase();
244
+ return typeof otherIdString === 'string' && otherIdString.toLowerCase() === thisIdString;
241
245
  }
242
246
 
243
247
  return false;
package/src/regexp.ts CHANGED
@@ -22,6 +22,7 @@ export interface BSONRegExpExtended {
22
22
  /**
23
23
  * A class representation of the BSON RegExp type.
24
24
  * @public
25
+ * @category BSONType
25
26
  */
26
27
  export class BSONRegExp {
27
28
  _bsontype!: 'BSONRegExp';
package/src/symbol.ts CHANGED
@@ -6,6 +6,7 @@ export interface BSONSymbolExtended {
6
6
  /**
7
7
  * A class representation of the BSON Symbol type.
8
8
  * @public
9
+ * @category BSONType
9
10
  */
10
11
  export class BSONSymbol {
11
12
  _bsontype!: 'Symbol';
package/src/timestamp.ts CHANGED
@@ -19,7 +19,10 @@ export interface TimestampExtended {
19
19
  };
20
20
  }
21
21
 
22
- /** @public */
22
+ /**
23
+ * @public
24
+ * @category BSONType
25
+ * */
23
26
  export class Timestamp extends LongWithoutOverridesClass {
24
27
  _bsontype!: 'Timestamp';
25
28