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/dist/bson.browser.umd.js
CHANGED
|
@@ -3806,9 +3806,15 @@
|
|
|
3806
3806
|
if (typeof bytes === 'string') {
|
|
3807
3807
|
this.bytes = Decimal128.fromString(bytes).bytes;
|
|
3808
3808
|
}
|
|
3809
|
-
else {
|
|
3809
|
+
else if (isUint8Array(bytes)) {
|
|
3810
|
+
if (bytes.byteLength !== 16) {
|
|
3811
|
+
throw new BSONTypeError('Decimal128 must take a Buffer of 16 bytes');
|
|
3812
|
+
}
|
|
3810
3813
|
this.bytes = bytes;
|
|
3811
3814
|
}
|
|
3815
|
+
else {
|
|
3816
|
+
throw new BSONTypeError('Decimal128 must take a Buffer or string');
|
|
3817
|
+
}
|
|
3812
3818
|
}
|
|
3813
3819
|
/**
|
|
3814
3820
|
* Create a Decimal128 instance from a string representation
|
|
@@ -4774,26 +4780,13 @@
|
|
|
4774
4780
|
ObjectId.isValid = function (id) {
|
|
4775
4781
|
if (id == null)
|
|
4776
4782
|
return false;
|
|
4777
|
-
|
|
4778
|
-
|
|
4779
|
-
}
|
|
4780
|
-
if (typeof id === 'string') {
|
|
4781
|
-
return id.length === 12 || (id.length === 24 && checkForHexRegExp.test(id));
|
|
4782
|
-
}
|
|
4783
|
-
if (id instanceof ObjectId) {
|
|
4784
|
-
return true;
|
|
4785
|
-
}
|
|
4786
|
-
if (isUint8Array(id) && id.length === 12) {
|
|
4783
|
+
try {
|
|
4784
|
+
new ObjectId(id);
|
|
4787
4785
|
return true;
|
|
4788
4786
|
}
|
|
4789
|
-
|
|
4790
|
-
|
|
4791
|
-
if (typeof id.id === 'string') {
|
|
4792
|
-
return id.id.length === 12;
|
|
4793
|
-
}
|
|
4794
|
-
return id.toHexString().length === 24 && checkForHexRegExp.test(id.id.toString('hex'));
|
|
4787
|
+
catch (_a) {
|
|
4788
|
+
return false;
|
|
4795
4789
|
}
|
|
4796
|
-
return false;
|
|
4797
4790
|
};
|
|
4798
4791
|
/** @internal */
|
|
4799
4792
|
ObjectId.prototype.toExtendedJSON = function () {
|
|
@@ -5589,7 +5582,7 @@
|
|
|
5589
5582
|
}
|
|
5590
5583
|
else {
|
|
5591
5584
|
// If we have toBSON defined, override the current object
|
|
5592
|
-
if (object.toBSON) {
|
|
5585
|
+
if (typeof (object === null || object === void 0 ? void 0 : object.toBSON) === 'function') {
|
|
5593
5586
|
object = object.toBSON();
|
|
5594
5587
|
}
|
|
5595
5588
|
// Calculate size
|
|
@@ -5607,7 +5600,7 @@
|
|
|
5607
5600
|
if (isArray === void 0) { isArray = false; }
|
|
5608
5601
|
if (ignoreUndefined === void 0) { ignoreUndefined = false; }
|
|
5609
5602
|
// If we have toBSON defined, override the current object
|
|
5610
|
-
if (value
|
|
5603
|
+
if (typeof (value === null || value === void 0 ? void 0 : value.toBSON) === 'function') {
|
|
5611
5604
|
value = value.toBSON();
|
|
5612
5605
|
}
|
|
5613
5606
|
switch (typeof value) {
|
|
@@ -7055,9 +7048,7 @@
|
|
|
7055
7048
|
var key = '' + i;
|
|
7056
7049
|
var value = object[i];
|
|
7057
7050
|
// Is there an override value
|
|
7058
|
-
if (value
|
|
7059
|
-
if (typeof value.toBSON !== 'function')
|
|
7060
|
-
throw new BSONTypeError('toBSON is not a function');
|
|
7051
|
+
if (typeof (value === null || value === void 0 ? void 0 : value.toBSON) === 'function') {
|
|
7061
7052
|
value = value.toBSON();
|
|
7062
7053
|
}
|
|
7063
7054
|
if (typeof value === 'string') {
|
|
@@ -7233,21 +7224,18 @@
|
|
|
7233
7224
|
}
|
|
7234
7225
|
}
|
|
7235
7226
|
else {
|
|
7236
|
-
|
|
7237
|
-
|
|
7238
|
-
if (typeof object.toBSON !== 'function')
|
|
7239
|
-
throw new BSONTypeError('toBSON is not a function');
|
|
7227
|
+
if (typeof (object === null || object === void 0 ? void 0 : object.toBSON) === 'function') {
|
|
7228
|
+
// Provided a custom serialization method
|
|
7240
7229
|
object = object.toBSON();
|
|
7241
|
-
if (object != null && typeof object !== 'object')
|
|
7230
|
+
if (object != null && typeof object !== 'object') {
|
|
7242
7231
|
throw new BSONTypeError('toBSON function did not return an object');
|
|
7232
|
+
}
|
|
7243
7233
|
}
|
|
7244
7234
|
// Iterate over all the keys
|
|
7245
7235
|
for (var key in object) {
|
|
7246
7236
|
var value = object[key];
|
|
7247
7237
|
// Is there an override value
|
|
7248
|
-
if (value
|
|
7249
|
-
if (typeof value.toBSON !== 'function')
|
|
7250
|
-
throw new BSONTypeError('toBSON is not a function');
|
|
7238
|
+
if (typeof (value === null || value === void 0 ? void 0 : value.toBSON) === 'function') {
|
|
7251
7239
|
value = value.toBSON();
|
|
7252
7240
|
}
|
|
7253
7241
|
// Check the type of the value
|