bson 4.6.0 → 4.6.3
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 +40 -35
- package/dist/bson.browser.esm.js.map +1 -1
- package/dist/bson.browser.umd.js +40 -35
- package/dist/bson.browser.umd.js.map +1 -1
- package/dist/bson.bundle.js +40 -35
- package/dist/bson.bundle.js.map +1 -1
- package/dist/bson.esm.js +40 -35
- 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 +9 -1
- 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 +10 -20
- 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/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 +8 -1
- 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 +13 -29
- package/src/parser/calculate_size.ts +2 -2
- package/src/parser/serializer.ts +6 -8
- package/src/regexp.ts +1 -0
- package/src/symbol.ts +1 -0
- package/src/timestamp.ts +4 -1
- package/HISTORY.md +0 -572
package/dist/bson.browser.umd.js
CHANGED
|
@@ -2450,6 +2450,7 @@
|
|
|
2450
2450
|
/**
|
|
2451
2451
|
* A class representation of the BSON Binary type.
|
|
2452
2452
|
* @public
|
|
2453
|
+
* @category BSONType
|
|
2453
2454
|
*/
|
|
2454
2455
|
var Binary = /** @class */ (function () {
|
|
2455
2456
|
/**
|
|
@@ -2680,6 +2681,7 @@
|
|
|
2680
2681
|
/**
|
|
2681
2682
|
* A class representation of the BSON Code type.
|
|
2682
2683
|
* @public
|
|
2684
|
+
* @category BSONType
|
|
2683
2685
|
*/
|
|
2684
2686
|
var Code = /** @class */ (function () {
|
|
2685
2687
|
/**
|
|
@@ -2728,6 +2730,7 @@
|
|
|
2728
2730
|
/**
|
|
2729
2731
|
* A class representation of the BSON DBRef type.
|
|
2730
2732
|
* @public
|
|
2733
|
+
* @category BSONType
|
|
2731
2734
|
*/
|
|
2732
2735
|
var DBRef = /** @class */ (function () {
|
|
2733
2736
|
/**
|
|
@@ -2832,6 +2835,7 @@
|
|
|
2832
2835
|
/**
|
|
2833
2836
|
* A class representing a 64-bit integer
|
|
2834
2837
|
* @public
|
|
2838
|
+
* @category BSONType
|
|
2835
2839
|
* @remarks
|
|
2836
2840
|
* The internal representation of a long is the two given signed, 32-bit values.
|
|
2837
2841
|
* We use 32-bit pieces because these are the size of integers on which
|
|
@@ -3794,6 +3798,7 @@
|
|
|
3794
3798
|
/**
|
|
3795
3799
|
* A class representation of the BSON Decimal128 type.
|
|
3796
3800
|
* @public
|
|
3801
|
+
* @category BSONType
|
|
3797
3802
|
*/
|
|
3798
3803
|
var Decimal128 = /** @class */ (function () {
|
|
3799
3804
|
/**
|
|
@@ -3806,9 +3811,15 @@
|
|
|
3806
3811
|
if (typeof bytes === 'string') {
|
|
3807
3812
|
this.bytes = Decimal128.fromString(bytes).bytes;
|
|
3808
3813
|
}
|
|
3809
|
-
else {
|
|
3814
|
+
else if (isUint8Array(bytes)) {
|
|
3815
|
+
if (bytes.byteLength !== 16) {
|
|
3816
|
+
throw new BSONTypeError('Decimal128 must take a Buffer of 16 bytes');
|
|
3817
|
+
}
|
|
3810
3818
|
this.bytes = bytes;
|
|
3811
3819
|
}
|
|
3820
|
+
else {
|
|
3821
|
+
throw new BSONTypeError('Decimal128 must take a Buffer or string');
|
|
3822
|
+
}
|
|
3812
3823
|
}
|
|
3813
3824
|
/**
|
|
3814
3825
|
* Create a Decimal128 instance from a string representation
|
|
@@ -4359,6 +4370,7 @@
|
|
|
4359
4370
|
/**
|
|
4360
4371
|
* A class representation of the BSON Double type.
|
|
4361
4372
|
* @public
|
|
4373
|
+
* @category BSONType
|
|
4362
4374
|
*/
|
|
4363
4375
|
var Double = /** @class */ (function () {
|
|
4364
4376
|
/**
|
|
@@ -4430,6 +4442,7 @@
|
|
|
4430
4442
|
/**
|
|
4431
4443
|
* A class representation of a BSON Int32 type.
|
|
4432
4444
|
* @public
|
|
4445
|
+
* @category BSONType
|
|
4433
4446
|
*/
|
|
4434
4447
|
var Int32 = /** @class */ (function () {
|
|
4435
4448
|
/**
|
|
@@ -4483,6 +4496,7 @@
|
|
|
4483
4496
|
/**
|
|
4484
4497
|
* A class representation of the BSON MaxKey type.
|
|
4485
4498
|
* @public
|
|
4499
|
+
* @category BSONType
|
|
4486
4500
|
*/
|
|
4487
4501
|
var MaxKey = /** @class */ (function () {
|
|
4488
4502
|
function MaxKey() {
|
|
@@ -4511,6 +4525,7 @@
|
|
|
4511
4525
|
/**
|
|
4512
4526
|
* A class representation of the BSON MinKey type.
|
|
4513
4527
|
* @public
|
|
4528
|
+
* @category BSONType
|
|
4514
4529
|
*/
|
|
4515
4530
|
var MinKey = /** @class */ (function () {
|
|
4516
4531
|
function MinKey() {
|
|
@@ -4544,6 +4559,7 @@
|
|
|
4544
4559
|
/**
|
|
4545
4560
|
* A class representation of the BSON ObjectId type.
|
|
4546
4561
|
* @public
|
|
4562
|
+
* @category BSONType
|
|
4547
4563
|
*/
|
|
4548
4564
|
var ObjectId = /** @class */ (function () {
|
|
4549
4565
|
/**
|
|
@@ -4593,7 +4609,7 @@
|
|
|
4593
4609
|
this[kId] = buffer_1.from(workingId, 'hex');
|
|
4594
4610
|
}
|
|
4595
4611
|
else {
|
|
4596
|
-
throw new BSONTypeError('Argument passed in must be a string of 12 bytes or a string of 24 hex characters');
|
|
4612
|
+
throw new BSONTypeError('Argument passed in must be a string of 12 bytes or a string of 24 hex characters or an integer');
|
|
4597
4613
|
}
|
|
4598
4614
|
}
|
|
4599
4615
|
else {
|
|
@@ -4710,7 +4726,7 @@
|
|
|
4710
4726
|
return false;
|
|
4711
4727
|
}
|
|
4712
4728
|
if (otherId instanceof ObjectId) {
|
|
4713
|
-
return this
|
|
4729
|
+
return this[kId][11] === otherId[kId][11] && this[kId].equals(otherId[kId]);
|
|
4714
4730
|
}
|
|
4715
4731
|
if (typeof otherId === 'string' &&
|
|
4716
4732
|
ObjectId.isValid(otherId) &&
|
|
@@ -4727,7 +4743,9 @@
|
|
|
4727
4743
|
if (typeof otherId === 'object' &&
|
|
4728
4744
|
'toHexString' in otherId &&
|
|
4729
4745
|
typeof otherId.toHexString === 'function') {
|
|
4730
|
-
|
|
4746
|
+
var otherIdString = otherId.toHexString();
|
|
4747
|
+
var thisIdString = this.toHexString().toLowerCase();
|
|
4748
|
+
return typeof otherIdString === 'string' && otherIdString.toLowerCase() === thisIdString;
|
|
4731
4749
|
}
|
|
4732
4750
|
return false;
|
|
4733
4751
|
};
|
|
@@ -4774,26 +4792,13 @@
|
|
|
4774
4792
|
ObjectId.isValid = function (id) {
|
|
4775
4793
|
if (id == null)
|
|
4776
4794
|
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) {
|
|
4795
|
+
try {
|
|
4796
|
+
new ObjectId(id);
|
|
4787
4797
|
return true;
|
|
4788
4798
|
}
|
|
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'));
|
|
4799
|
+
catch (_a) {
|
|
4800
|
+
return false;
|
|
4795
4801
|
}
|
|
4796
|
-
return false;
|
|
4797
4802
|
};
|
|
4798
4803
|
/** @internal */
|
|
4799
4804
|
ObjectId.prototype.toExtendedJSON = function () {
|
|
@@ -4842,6 +4847,7 @@
|
|
|
4842
4847
|
/**
|
|
4843
4848
|
* A class representation of the BSON RegExp type.
|
|
4844
4849
|
* @public
|
|
4850
|
+
* @category BSONType
|
|
4845
4851
|
*/
|
|
4846
4852
|
var BSONRegExp = /** @class */ (function () {
|
|
4847
4853
|
/**
|
|
@@ -4907,6 +4913,7 @@
|
|
|
4907
4913
|
/**
|
|
4908
4914
|
* A class representation of the BSON Symbol type.
|
|
4909
4915
|
* @public
|
|
4916
|
+
* @category BSONType
|
|
4910
4917
|
*/
|
|
4911
4918
|
var BSONSymbol = /** @class */ (function () {
|
|
4912
4919
|
/**
|
|
@@ -4949,7 +4956,10 @@
|
|
|
4949
4956
|
|
|
4950
4957
|
/** @public */
|
|
4951
4958
|
var LongWithoutOverridesClass = Long;
|
|
4952
|
-
/**
|
|
4959
|
+
/**
|
|
4960
|
+
* @public
|
|
4961
|
+
* @category BSONType
|
|
4962
|
+
* */
|
|
4953
4963
|
var Timestamp = /** @class */ (function (_super) {
|
|
4954
4964
|
__extends(Timestamp, _super);
|
|
4955
4965
|
function Timestamp(low, high) {
|
|
@@ -5589,7 +5599,7 @@
|
|
|
5589
5599
|
}
|
|
5590
5600
|
else {
|
|
5591
5601
|
// If we have toBSON defined, override the current object
|
|
5592
|
-
if (object.toBSON) {
|
|
5602
|
+
if (typeof (object === null || object === void 0 ? void 0 : object.toBSON) === 'function') {
|
|
5593
5603
|
object = object.toBSON();
|
|
5594
5604
|
}
|
|
5595
5605
|
// Calculate size
|
|
@@ -5607,7 +5617,7 @@
|
|
|
5607
5617
|
if (isArray === void 0) { isArray = false; }
|
|
5608
5618
|
if (ignoreUndefined === void 0) { ignoreUndefined = false; }
|
|
5609
5619
|
// If we have toBSON defined, override the current object
|
|
5610
|
-
if (value
|
|
5620
|
+
if (typeof (value === null || value === void 0 ? void 0 : value.toBSON) === 'function') {
|
|
5611
5621
|
value = value.toBSON();
|
|
5612
5622
|
}
|
|
5613
5623
|
switch (typeof value) {
|
|
@@ -7055,9 +7065,7 @@
|
|
|
7055
7065
|
var key = '' + i;
|
|
7056
7066
|
var value = object[i];
|
|
7057
7067
|
// Is there an override value
|
|
7058
|
-
if (value
|
|
7059
|
-
if (typeof value.toBSON !== 'function')
|
|
7060
|
-
throw new BSONTypeError('toBSON is not a function');
|
|
7068
|
+
if (typeof (value === null || value === void 0 ? void 0 : value.toBSON) === 'function') {
|
|
7061
7069
|
value = value.toBSON();
|
|
7062
7070
|
}
|
|
7063
7071
|
if (typeof value === 'string') {
|
|
@@ -7233,21 +7241,18 @@
|
|
|
7233
7241
|
}
|
|
7234
7242
|
}
|
|
7235
7243
|
else {
|
|
7236
|
-
|
|
7237
|
-
|
|
7238
|
-
if (typeof object.toBSON !== 'function')
|
|
7239
|
-
throw new BSONTypeError('toBSON is not a function');
|
|
7244
|
+
if (typeof (object === null || object === void 0 ? void 0 : object.toBSON) === 'function') {
|
|
7245
|
+
// Provided a custom serialization method
|
|
7240
7246
|
object = object.toBSON();
|
|
7241
|
-
if (object != null && typeof object !== 'object')
|
|
7247
|
+
if (object != null && typeof object !== 'object') {
|
|
7242
7248
|
throw new BSONTypeError('toBSON function did not return an object');
|
|
7249
|
+
}
|
|
7243
7250
|
}
|
|
7244
7251
|
// Iterate over all the keys
|
|
7245
7252
|
for (var key in object) {
|
|
7246
7253
|
var value = object[key];
|
|
7247
7254
|
// Is there an override value
|
|
7248
|
-
if (value
|
|
7249
|
-
if (typeof value.toBSON !== 'function')
|
|
7250
|
-
throw new BSONTypeError('toBSON is not a function');
|
|
7255
|
+
if (typeof (value === null || value === void 0 ? void 0 : value.toBSON) === 'function') {
|
|
7251
7256
|
value = value.toBSON();
|
|
7252
7257
|
}
|
|
7253
7258
|
// Check the type of the value
|