bson 7.0.0-alpha.1 → 7.0.0
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/README.md +7 -6
- package/bson.d.ts +0 -1
- package/lib/bson.bundle.js +11 -8
- package/lib/bson.bundle.js.map +1 -1
- package/lib/bson.cjs +11 -8
- package/lib/bson.cjs.map +1 -1
- package/lib/bson.mjs +11 -8
- package/lib/bson.mjs.map +1 -1
- package/lib/bson.node.mjs +11 -8
- package/lib/bson.node.mjs.map +1 -1
- package/lib/bson.rn.cjs +11 -8
- package/lib/bson.rn.cjs.map +1 -1
- package/package.json +2 -3
- package/src/objectid.ts +13 -20
package/README.md
CHANGED
|
@@ -99,12 +99,13 @@ npm install bson
|
|
|
99
99
|
|
|
100
100
|
Only the following version combinations with the [MongoDB Node.js Driver](https://github.com/mongodb/node-mongodb-native) are considered stable.
|
|
101
101
|
|
|
102
|
-
| | `bson@1.x` | `bson@4.x` | `bson@5.x` | `bson@6.x` |
|
|
103
|
-
| ------------- | ---------- | ---------- | ---------- | ---------- |
|
|
104
|
-
| `mongodb@
|
|
105
|
-
| `mongodb@
|
|
106
|
-
| `mongodb@
|
|
107
|
-
| `mongodb@
|
|
102
|
+
| | `bson@1.x` | `bson@4.x` | `bson@5.x` | `bson@6.x` | `bson@7.x` |
|
|
103
|
+
| ------------- | ---------- | ---------- | ---------- | ---------- | ---------- |
|
|
104
|
+
| `mongodb@7.x` | N/A | N/A | N/A | N/A | ✓ |
|
|
105
|
+
| `mongodb@6.x` | N/A | N/A | N/A | ✓ | N/A |
|
|
106
|
+
| `mongodb@5.x` | N/A | N/A | ✓ | N/A | N/A |
|
|
107
|
+
| `mongodb@4.x` | N/A | ✓ | N/A | N/A | N/A |
|
|
108
|
+
| `mongodb@3.x` | ✓ | N/A | N/A | N/A | N/A |
|
|
108
109
|
|
|
109
110
|
## Documentation
|
|
110
111
|
|
package/bson.d.ts
CHANGED
|
@@ -1353,7 +1353,6 @@ declare const NumberUtils: NumberUtils;
|
|
|
1353
1353
|
* @category BSONType
|
|
1354
1354
|
*/
|
|
1355
1355
|
export declare class ObjectId extends BSONValue {
|
|
1356
|
-
#private;
|
|
1357
1356
|
get _bsontype(): 'ObjectId';
|
|
1358
1357
|
/* Excluded from this release type: index */
|
|
1359
1358
|
static cacheHexString: boolean;
|
package/lib/bson.bundle.js
CHANGED
|
@@ -2524,14 +2524,14 @@ class MinKey extends BSONValue {
|
|
|
2524
2524
|
}
|
|
2525
2525
|
|
|
2526
2526
|
let PROCESS_UNIQUE = null;
|
|
2527
|
+
const __idCache = new WeakMap();
|
|
2527
2528
|
class ObjectId extends BSONValue {
|
|
2528
2529
|
get _bsontype() {
|
|
2529
2530
|
return 'ObjectId';
|
|
2530
2531
|
}
|
|
2531
2532
|
static index = Math.floor(Math.random() * 0xffffff);
|
|
2532
|
-
static cacheHexString
|
|
2533
|
+
static cacheHexString;
|
|
2533
2534
|
buffer;
|
|
2534
|
-
#cachedHexString = null;
|
|
2535
2535
|
constructor(inputId) {
|
|
2536
2536
|
super();
|
|
2537
2537
|
let workingId;
|
|
@@ -2559,7 +2559,7 @@ class ObjectId extends BSONValue {
|
|
|
2559
2559
|
if (ObjectId.validateHexString(workingId)) {
|
|
2560
2560
|
this.buffer = ByteUtils.fromHex(workingId);
|
|
2561
2561
|
if (ObjectId.cacheHexString) {
|
|
2562
|
-
this
|
|
2562
|
+
__idCache.set(this, workingId);
|
|
2563
2563
|
}
|
|
2564
2564
|
}
|
|
2565
2565
|
else {
|
|
@@ -2576,7 +2576,7 @@ class ObjectId extends BSONValue {
|
|
|
2576
2576
|
set id(value) {
|
|
2577
2577
|
this.buffer = value;
|
|
2578
2578
|
if (ObjectId.cacheHexString) {
|
|
2579
|
-
this
|
|
2579
|
+
__idCache.set(this, ByteUtils.toHex(value));
|
|
2580
2580
|
}
|
|
2581
2581
|
}
|
|
2582
2582
|
static validateHexString(string) {
|
|
@@ -2594,11 +2594,14 @@ class ObjectId extends BSONValue {
|
|
|
2594
2594
|
return true;
|
|
2595
2595
|
}
|
|
2596
2596
|
toHexString() {
|
|
2597
|
-
if (
|
|
2598
|
-
|
|
2597
|
+
if (ObjectId.cacheHexString) {
|
|
2598
|
+
const __id = __idCache.get(this);
|
|
2599
|
+
if (__id)
|
|
2600
|
+
return __id;
|
|
2601
|
+
}
|
|
2599
2602
|
const hexString = ByteUtils.toHex(this.id);
|
|
2600
2603
|
if (ObjectId.cacheHexString) {
|
|
2601
|
-
this
|
|
2604
|
+
__idCache.set(this, hexString);
|
|
2602
2605
|
}
|
|
2603
2606
|
return hexString;
|
|
2604
2607
|
}
|
|
@@ -2723,7 +2726,7 @@ class ObjectId extends BSONValue {
|
|
|
2723
2726
|
return new ObjectId(doc.$oid);
|
|
2724
2727
|
}
|
|
2725
2728
|
isCached() {
|
|
2726
|
-
return ObjectId.cacheHexString && this
|
|
2729
|
+
return ObjectId.cacheHexString && __idCache.has(this);
|
|
2727
2730
|
}
|
|
2728
2731
|
inspect(depth, options, inspect) {
|
|
2729
2732
|
inspect ??= defaultInspect;
|