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.
- package/bower.json +1 -1
- package/bson-ts34.d.ts +1133 -0
- package/bson.d.ts +1228 -1118
- package/dist/bson.browser.esm.js +23 -5
- package/dist/bson.browser.esm.js.map +1 -1
- package/dist/bson.browser.umd.js +23 -5
- package/dist/bson.browser.umd.js.map +1 -1
- package/dist/bson.bundle.js +23 -5
- package/dist/bson.bundle.js.map +1 -1
- package/dist/bson.esm.js +23 -5
- package/dist/bson.esm.js.map +1 -1
- package/lib/binary.js +1 -0
- package/lib/binary.js.map +1 -1
- package/lib/code.js +1 -0
- package/lib/code.js.map +1 -1
- package/lib/db_ref.js +1 -0
- package/lib/db_ref.js.map +1 -1
- package/lib/decimal128.js +1 -0
- package/lib/decimal128.js.map +1 -1
- package/lib/double.js +1 -0
- package/lib/double.js.map +1 -1
- package/lib/int_32.js +1 -0
- package/lib/int_32.js.map +1 -1
- package/lib/long.js +1 -0
- package/lib/long.js.map +1 -1
- package/lib/max_key.js +1 -0
- package/lib/max_key.js.map +1 -1
- package/lib/min_key.js +1 -0
- package/lib/min_key.js.map +1 -1
- package/lib/objectid.js +8 -4
- package/lib/objectid.js.map +1 -1
- package/lib/regexp.js +1 -0
- package/lib/regexp.js.map +1 -1
- package/lib/symbol.js +1 -0
- package/lib/symbol.js.map +1 -1
- package/lib/timestamp.js +4 -1
- package/lib/timestamp.js.map +1 -1
- package/package.json +11 -3
- package/src/binary.ts +1 -0
- package/src/code.ts +1 -0
- package/src/db_ref.ts +1 -0
- package/src/decimal128.ts +1 -0
- package/src/double.ts +1 -0
- package/src/int_32.ts +1 -0
- package/src/long.ts +1 -0
- package/src/max_key.ts +1 -0
- package/src/min_key.ts +1 -0
- package/src/objectid.ts +9 -5
- package/src/regexp.ts +1 -0
- package/src/symbol.ts +1 -0
- 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
|
-
"
|
|
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.
|
|
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
package/src/code.ts
CHANGED
package/src/db_ref.ts
CHANGED
package/src/decimal128.ts
CHANGED
package/src/double.ts
CHANGED
package/src/int_32.ts
CHANGED
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
package/src/min_key.ts
CHANGED
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!: '
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
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
package/src/symbol.ts
CHANGED