bson 4.6.0 → 4.6.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.
- package/bower.json +1 -1
- package/bson.d.ts +2 -2
- package/dist/bson.browser.esm.js +19 -31
- package/dist/bson.browser.esm.js.map +1 -1
- package/dist/bson.browser.umd.js +19 -31
- package/dist/bson.browser.umd.js.map +1 -1
- package/dist/bson.bundle.js +19 -31
- package/dist/bson.bundle.js.map +1 -1
- package/dist/bson.esm.js +19 -31
- package/dist/bson.esm.js.map +1 -1
- package/lib/decimal128.js +8 -1
- package/lib/decimal128.js.map +1 -1
- package/lib/objectid.js +4 -17
- package/lib/objectid.js.map +1 -1
- package/lib/parser/calculate_size.js +2 -2
- package/lib/parser/calculate_size.js.map +1 -1
- package/lib/parser/serializer.js +6 -11
- package/lib/parser/serializer.js.map +1 -1
- package/package.json +1 -1
- package/src/decimal128.ts +7 -1
- package/src/objectid.ts +6 -25
- package/src/parser/calculate_size.ts +2 -2
- package/src/parser/serializer.ts +6 -8
- package/HISTORY.md +0 -572
package/bower.json
CHANGED
package/bson.d.ts
CHANGED
|
@@ -885,7 +885,7 @@ declare class ObjectId {
|
|
|
885
885
|
*
|
|
886
886
|
* @param inputId - Can be a 24 character hex string, 12 byte binary Buffer, or a number.
|
|
887
887
|
*/
|
|
888
|
-
constructor(inputId?: string |
|
|
888
|
+
constructor(inputId?: string | number | ObjectId | ObjectIdLike | Buffer | Uint8Array);
|
|
889
889
|
/*
|
|
890
890
|
* The ObjectId bytes
|
|
891
891
|
* @readonly
|
|
@@ -939,7 +939,7 @@ declare class ObjectId {
|
|
|
939
939
|
*
|
|
940
940
|
* @param id - ObjectId instance to validate.
|
|
941
941
|
*/
|
|
942
|
-
static isValid(id:
|
|
942
|
+
static isValid(id: string | number | ObjectId | ObjectIdLike | Buffer | Uint8Array): boolean;
|
|
943
943
|
/* Excluded from this release type: toExtendedJSON */
|
|
944
944
|
/* Excluded from this release type: fromExtendedJSON */
|
|
945
945
|
inspect(): string;
|
package/dist/bson.browser.esm.js
CHANGED
|
@@ -3800,9 +3800,15 @@ var Decimal128 = /** @class */ (function () {
|
|
|
3800
3800
|
if (typeof bytes === 'string') {
|
|
3801
3801
|
this.bytes = Decimal128.fromString(bytes).bytes;
|
|
3802
3802
|
}
|
|
3803
|
-
else {
|
|
3803
|
+
else if (isUint8Array(bytes)) {
|
|
3804
|
+
if (bytes.byteLength !== 16) {
|
|
3805
|
+
throw new BSONTypeError('Decimal128 must take a Buffer of 16 bytes');
|
|
3806
|
+
}
|
|
3804
3807
|
this.bytes = bytes;
|
|
3805
3808
|
}
|
|
3809
|
+
else {
|
|
3810
|
+
throw new BSONTypeError('Decimal128 must take a Buffer or string');
|
|
3811
|
+
}
|
|
3806
3812
|
}
|
|
3807
3813
|
/**
|
|
3808
3814
|
* Create a Decimal128 instance from a string representation
|
|
@@ -4768,26 +4774,13 @@ var ObjectId = /** @class */ (function () {
|
|
|
4768
4774
|
ObjectId.isValid = function (id) {
|
|
4769
4775
|
if (id == null)
|
|
4770
4776
|
return false;
|
|
4771
|
-
|
|
4772
|
-
|
|
4773
|
-
}
|
|
4774
|
-
if (typeof id === 'string') {
|
|
4775
|
-
return id.length === 12 || (id.length === 24 && checkForHexRegExp.test(id));
|
|
4776
|
-
}
|
|
4777
|
-
if (id instanceof ObjectId) {
|
|
4778
|
-
return true;
|
|
4779
|
-
}
|
|
4780
|
-
if (isUint8Array(id) && id.length === 12) {
|
|
4777
|
+
try {
|
|
4778
|
+
new ObjectId(id);
|
|
4781
4779
|
return true;
|
|
4782
4780
|
}
|
|
4783
|
-
|
|
4784
|
-
|
|
4785
|
-
if (typeof id.id === 'string') {
|
|
4786
|
-
return id.id.length === 12;
|
|
4787
|
-
}
|
|
4788
|
-
return id.toHexString().length === 24 && checkForHexRegExp.test(id.id.toString('hex'));
|
|
4781
|
+
catch (_a) {
|
|
4782
|
+
return false;
|
|
4789
4783
|
}
|
|
4790
|
-
return false;
|
|
4791
4784
|
};
|
|
4792
4785
|
/** @internal */
|
|
4793
4786
|
ObjectId.prototype.toExtendedJSON = function () {
|
|
@@ -5583,7 +5576,7 @@ function calculateObjectSize$1(object, serializeFunctions, ignoreUndefined) {
|
|
|
5583
5576
|
}
|
|
5584
5577
|
else {
|
|
5585
5578
|
// If we have toBSON defined, override the current object
|
|
5586
|
-
if (object.toBSON) {
|
|
5579
|
+
if (typeof (object === null || object === void 0 ? void 0 : object.toBSON) === 'function') {
|
|
5587
5580
|
object = object.toBSON();
|
|
5588
5581
|
}
|
|
5589
5582
|
// Calculate size
|
|
@@ -5601,7 +5594,7 @@ value, serializeFunctions, isArray, ignoreUndefined) {
|
|
|
5601
5594
|
if (isArray === void 0) { isArray = false; }
|
|
5602
5595
|
if (ignoreUndefined === void 0) { ignoreUndefined = false; }
|
|
5603
5596
|
// If we have toBSON defined, override the current object
|
|
5604
|
-
if (value
|
|
5597
|
+
if (typeof (value === null || value === void 0 ? void 0 : value.toBSON) === 'function') {
|
|
5605
5598
|
value = value.toBSON();
|
|
5606
5599
|
}
|
|
5607
5600
|
switch (typeof value) {
|
|
@@ -7049,9 +7042,7 @@ function serializeInto(buffer, object, checkKeys, startingIndex, depth, serializ
|
|
|
7049
7042
|
var key = '' + i;
|
|
7050
7043
|
var value = object[i];
|
|
7051
7044
|
// Is there an override value
|
|
7052
|
-
if (value
|
|
7053
|
-
if (typeof value.toBSON !== 'function')
|
|
7054
|
-
throw new BSONTypeError('toBSON is not a function');
|
|
7045
|
+
if (typeof (value === null || value === void 0 ? void 0 : value.toBSON) === 'function') {
|
|
7055
7046
|
value = value.toBSON();
|
|
7056
7047
|
}
|
|
7057
7048
|
if (typeof value === 'string') {
|
|
@@ -7227,21 +7218,18 @@ function serializeInto(buffer, object, checkKeys, startingIndex, depth, serializ
|
|
|
7227
7218
|
}
|
|
7228
7219
|
}
|
|
7229
7220
|
else {
|
|
7230
|
-
|
|
7231
|
-
|
|
7232
|
-
if (typeof object.toBSON !== 'function')
|
|
7233
|
-
throw new BSONTypeError('toBSON is not a function');
|
|
7221
|
+
if (typeof (object === null || object === void 0 ? void 0 : object.toBSON) === 'function') {
|
|
7222
|
+
// Provided a custom serialization method
|
|
7234
7223
|
object = object.toBSON();
|
|
7235
|
-
if (object != null && typeof object !== 'object')
|
|
7224
|
+
if (object != null && typeof object !== 'object') {
|
|
7236
7225
|
throw new BSONTypeError('toBSON function did not return an object');
|
|
7226
|
+
}
|
|
7237
7227
|
}
|
|
7238
7228
|
// Iterate over all the keys
|
|
7239
7229
|
for (var key in object) {
|
|
7240
7230
|
var value = object[key];
|
|
7241
7231
|
// Is there an override value
|
|
7242
|
-
if (value
|
|
7243
|
-
if (typeof value.toBSON !== 'function')
|
|
7244
|
-
throw new BSONTypeError('toBSON is not a function');
|
|
7232
|
+
if (typeof (value === null || value === void 0 ? void 0 : value.toBSON) === 'function') {
|
|
7245
7233
|
value = value.toBSON();
|
|
7246
7234
|
}
|
|
7247
7235
|
// Check the type of the value
|