bson 4.2.2 → 4.2.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/HISTORY.md +10 -0
- package/bower.json +1 -1
- package/bson.d.ts +3 -0
- package/dist/bson.browser.esm.js +1507 -952
- package/dist/bson.browser.esm.js.map +1 -1
- package/dist/bson.browser.umd.js +1507 -952
- package/dist/bson.browser.umd.js.map +1 -1
- package/dist/bson.bundle.js +1507 -952
- package/dist/bson.bundle.js.map +1 -1
- package/dist/bson.esm.js +1507 -952
- package/dist/bson.esm.js.map +1 -1
- package/lib/binary.js +62 -59
- package/lib/binary.js.map +1 -1
- package/lib/bson.js +55 -51
- package/lib/bson.js.map +1 -1
- package/lib/code.js +18 -15
- package/lib/code.js.map +1 -1
- package/lib/db_ref.js +36 -29
- package/lib/db_ref.js.map +1 -1
- package/lib/decimal128.js +125 -122
- package/lib/decimal128.js.map +1 -1
- package/lib/double.js +24 -21
- package/lib/double.js.map +1 -1
- package/lib/ensure_buffer.js +2 -2
- package/lib/ensure_buffer.js.map +1 -1
- package/lib/extended_json.js +67 -64
- package/lib/extended_json.js.map +1 -1
- package/lib/float_parser.js +21 -21
- package/lib/float_parser.js.map +1 -1
- package/lib/int_32.js +19 -16
- package/lib/int_32.js.map +1 -1
- package/lib/long.js +232 -227
- package/lib/long.js.map +1 -1
- package/lib/map.js +54 -45
- package/lib/map.js.map +1 -1
- package/lib/max_key.js +16 -11
- package/lib/max_key.js.map +1 -1
- package/lib/min_key.js +16 -11
- package/lib/min_key.js.map +1 -1
- package/lib/objectid.js +93 -82
- package/lib/objectid.js.map +1 -1
- package/lib/parser/calculate_size.js +12 -9
- package/lib/parser/calculate_size.js.map +1 -1
- package/lib/parser/deserializer.js +89 -88
- package/lib/parser/deserializer.js.map +1 -1
- package/lib/parser/serializer.js +94 -75
- package/lib/parser/serializer.js.map +1 -1
- package/lib/parser/utils.js +19 -8
- package/lib/parser/utils.js.map +1 -1
- package/lib/regexp.js +15 -12
- package/lib/regexp.js.map +1 -1
- package/lib/symbol.js +21 -18
- package/lib/symbol.js.map +1 -1
- package/lib/timestamp.js +48 -27
- package/lib/timestamp.js.map +1 -1
- package/lib/uuid.js +3 -3
- package/lib/uuid.js.map +1 -1
- package/lib/validate_utf8.js +12 -12
- package/lib/validate_utf8.js.map +1 -1
- package/package.json +1 -1
- package/src/binary.ts +6 -4
- package/src/code.ts +6 -2
- package/src/db_ref.ts +8 -4
- package/src/decimal128.ts +4 -2
- package/src/double.ts +4 -2
- package/src/int_32.ts +4 -2
- package/src/long.ts +6 -4
- package/src/max_key.ts +5 -1
- package/src/min_key.ts +5 -1
- package/src/objectid.ts +3 -1
- package/src/parser/utils.ts +1 -1
- package/src/regexp.ts +4 -2
- package/src/symbol.ts +4 -2
- package/src/timestamp.ts +6 -1
package/lib/parser/utils.js
CHANGED
|
@@ -1,7 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __spreadArrays = (this && this.__spreadArrays) || function () {
|
|
3
|
+
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
|
|
4
|
+
for (var r = Array(s), k = 0, i = 0; i < il; i++)
|
|
5
|
+
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
|
|
6
|
+
r[k] = a[j];
|
|
7
|
+
return r;
|
|
8
|
+
};
|
|
2
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
10
|
exports.deprecate = exports.isObjectLike = exports.isDate = exports.isBuffer = exports.haveBuffer = exports.isBigUInt64Array = exports.isBigInt64Array = exports.isUint8Array = exports.randomBytes = exports.normalizedFunctionString = void 0;
|
|
4
|
-
|
|
11
|
+
var buffer_1 = require("buffer");
|
|
5
12
|
/**
|
|
6
13
|
* Normalizes our expected stringified form of a function across versions of node
|
|
7
14
|
* @param fn - The function to stringify
|
|
@@ -11,14 +18,14 @@ function normalizedFunctionString(fn) {
|
|
|
11
18
|
}
|
|
12
19
|
exports.normalizedFunctionString = normalizedFunctionString;
|
|
13
20
|
function insecureRandomBytes(size) {
|
|
14
|
-
|
|
15
|
-
for (
|
|
21
|
+
var result = buffer_1.Buffer.alloc(size);
|
|
22
|
+
for (var i = 0; i < size; ++i)
|
|
16
23
|
result[i] = Math.floor(Math.random() * 256);
|
|
17
24
|
return result;
|
|
18
25
|
}
|
|
19
26
|
exports.randomBytes = insecureRandomBytes;
|
|
20
27
|
if (typeof window !== 'undefined' && window.crypto && window.crypto.getRandomValues) {
|
|
21
|
-
exports.randomBytes = size
|
|
28
|
+
exports.randomBytes = function (size) { return window.crypto.getRandomValues(buffer_1.Buffer.alloc(size)); };
|
|
22
29
|
}
|
|
23
30
|
else {
|
|
24
31
|
try {
|
|
@@ -71,17 +78,21 @@ function isObjectLike(candidate) {
|
|
|
71
78
|
}
|
|
72
79
|
exports.isObjectLike = isObjectLike;
|
|
73
80
|
function deprecate(fn, message) {
|
|
74
|
-
if (typeof window === 'undefined'
|
|
81
|
+
if (typeof window === 'undefined' && typeof self === 'undefined') {
|
|
75
82
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
76
83
|
return require('util').deprecate(fn, message);
|
|
77
84
|
}
|
|
78
|
-
|
|
79
|
-
function deprecated(
|
|
85
|
+
var warned = false;
|
|
86
|
+
function deprecated() {
|
|
87
|
+
var args = [];
|
|
88
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
89
|
+
args[_i] = arguments[_i];
|
|
90
|
+
}
|
|
80
91
|
if (!warned) {
|
|
81
92
|
console.warn(message);
|
|
82
93
|
warned = true;
|
|
83
94
|
}
|
|
84
|
-
return fn.apply(this,
|
|
95
|
+
return fn.apply.apply(fn, __spreadArrays([this], args));
|
|
85
96
|
}
|
|
86
97
|
return deprecated;
|
|
87
98
|
}
|
package/lib/parser/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/parser/utils.ts"],"names":[],"mappings":"
|
|
1
|
+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AI,MAAM,GAAG,KAAK,CAAC;IACnB,SAAS,UAAU;QAAgB,cAAkB;aAAlB,UAAkB,EAAlB,qBAAkB,EAAlB,IAAkB;YAAlB,yBAAkB;;QACnD,IAAI,CAAC,MAAM,EAAE;YACX,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;YACtB,MAAM,GAAG,IAAI,CAAC;SACf;QACD,OAAO,EAAE,CAAC,KAAK,OAAR,EAAE,kBAAO,IAAI,GAAK,IAAI,GAAE;IACjC,CAAC;IACD,OAAQ,UAA2B,CAAC;AACtC,CAAC;AAdD,8BAcC"}
|
package/lib/regexp.js
CHANGED
|
@@ -8,41 +8,43 @@ function alphabetize(str) {
|
|
|
8
8
|
* A class representation of the BSON RegExp type.
|
|
9
9
|
* @public
|
|
10
10
|
*/
|
|
11
|
-
|
|
11
|
+
var BSONRegExp = /** @class */ (function () {
|
|
12
12
|
/**
|
|
13
13
|
* @param pattern - The regular expression pattern to match
|
|
14
14
|
* @param options - The regular expression options
|
|
15
15
|
*/
|
|
16
|
-
|
|
16
|
+
function BSONRegExp(pattern, options) {
|
|
17
|
+
if (!(this instanceof BSONRegExp))
|
|
18
|
+
return new BSONRegExp(pattern, options);
|
|
17
19
|
this.pattern = pattern;
|
|
18
20
|
this.options = options !== null && options !== void 0 ? options : '';
|
|
19
21
|
// Execute
|
|
20
22
|
alphabetize(this.options);
|
|
21
23
|
// Validate options
|
|
22
|
-
for (
|
|
24
|
+
for (var i = 0; i < this.options.length; i++) {
|
|
23
25
|
if (!(this.options[i] === 'i' ||
|
|
24
26
|
this.options[i] === 'm' ||
|
|
25
27
|
this.options[i] === 'x' ||
|
|
26
28
|
this.options[i] === 'l' ||
|
|
27
29
|
this.options[i] === 's' ||
|
|
28
30
|
this.options[i] === 'u')) {
|
|
29
|
-
throw new Error(
|
|
31
|
+
throw new Error("The regular expression option [" + this.options[i] + "] is not supported");
|
|
30
32
|
}
|
|
31
33
|
}
|
|
32
34
|
}
|
|
33
|
-
|
|
35
|
+
BSONRegExp.parseOptions = function (options) {
|
|
34
36
|
return options ? options.split('').sort().join('') : '';
|
|
35
|
-
}
|
|
37
|
+
};
|
|
36
38
|
/** @internal */
|
|
37
|
-
toExtendedJSON(options) {
|
|
39
|
+
BSONRegExp.prototype.toExtendedJSON = function (options) {
|
|
38
40
|
options = options || {};
|
|
39
41
|
if (options.legacy) {
|
|
40
42
|
return { $regex: this.pattern, $options: this.options };
|
|
41
43
|
}
|
|
42
44
|
return { $regularExpression: { pattern: this.pattern, options: this.options } };
|
|
43
|
-
}
|
|
45
|
+
};
|
|
44
46
|
/** @internal */
|
|
45
|
-
|
|
47
|
+
BSONRegExp.fromExtendedJSON = function (doc) {
|
|
46
48
|
if ('$regex' in doc) {
|
|
47
49
|
if (typeof doc.$regex !== 'string') {
|
|
48
50
|
// This is for $regex query operators that have extended json values.
|
|
@@ -57,9 +59,10 @@ class BSONRegExp {
|
|
|
57
59
|
if ('$regularExpression' in doc) {
|
|
58
60
|
return new BSONRegExp(doc.$regularExpression.pattern, BSONRegExp.parseOptions(doc.$regularExpression.options));
|
|
59
61
|
}
|
|
60
|
-
throw new TypeError(
|
|
61
|
-
}
|
|
62
|
-
|
|
62
|
+
throw new TypeError("Unexpected BSONRegExp EJSON object form: " + JSON.stringify(doc));
|
|
63
|
+
};
|
|
64
|
+
return BSONRegExp;
|
|
65
|
+
}());
|
|
63
66
|
exports.BSONRegExp = BSONRegExp;
|
|
64
67
|
Object.defineProperty(BSONRegExp.prototype, '_bsontype', { value: 'BSONRegExp' });
|
|
65
68
|
//# sourceMappingURL=regexp.js.map
|
package/lib/regexp.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"regexp.js","sourceRoot":"","sources":["../src/regexp.ts"],"names":[],"mappings":";;;AAEA,SAAS,WAAW,CAAC,GAAW;IAC9B,OAAO,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC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C;AAAD,CAAC,AAnED,IAmEC;AAnEY,gCAAU;AAqEvB,MAAM,CAAC,cAAc,CAAC,UAAU,CAAC,SAAS,EAAE,WAAW,EAAE,EAAE,KAAK,EAAE,YAAY,EAAE,CAAC,CAAC"}
|
package/lib/symbol.js
CHANGED
|
@@ -5,42 +5,45 @@ exports.BSONSymbol = void 0;
|
|
|
5
5
|
* A class representation of the BSON Symbol type.
|
|
6
6
|
* @public
|
|
7
7
|
*/
|
|
8
|
-
|
|
8
|
+
var BSONSymbol = /** @class */ (function () {
|
|
9
9
|
/**
|
|
10
10
|
* @param value - the string representing the symbol.
|
|
11
11
|
*/
|
|
12
|
-
|
|
12
|
+
function BSONSymbol(value) {
|
|
13
|
+
if (!(this instanceof BSONSymbol))
|
|
14
|
+
return new BSONSymbol(value);
|
|
13
15
|
this.value = value;
|
|
14
16
|
}
|
|
15
17
|
/** Access the wrapped string value. */
|
|
16
|
-
valueOf() {
|
|
18
|
+
BSONSymbol.prototype.valueOf = function () {
|
|
17
19
|
return this.value;
|
|
18
|
-
}
|
|
20
|
+
};
|
|
19
21
|
/** @internal */
|
|
20
|
-
toString() {
|
|
22
|
+
BSONSymbol.prototype.toString = function () {
|
|
21
23
|
return this.value;
|
|
22
|
-
}
|
|
24
|
+
};
|
|
23
25
|
/** @internal */
|
|
24
|
-
inspect() {
|
|
25
|
-
return
|
|
26
|
-
}
|
|
26
|
+
BSONSymbol.prototype.inspect = function () {
|
|
27
|
+
return "new BSONSymbol(\"" + this.value + "\")";
|
|
28
|
+
};
|
|
27
29
|
/** @internal */
|
|
28
|
-
toJSON() {
|
|
30
|
+
BSONSymbol.prototype.toJSON = function () {
|
|
29
31
|
return this.value;
|
|
30
|
-
}
|
|
32
|
+
};
|
|
31
33
|
/** @internal */
|
|
32
|
-
toExtendedJSON() {
|
|
34
|
+
BSONSymbol.prototype.toExtendedJSON = function () {
|
|
33
35
|
return { $symbol: this.value };
|
|
34
|
-
}
|
|
36
|
+
};
|
|
35
37
|
/** @internal */
|
|
36
|
-
|
|
38
|
+
BSONSymbol.fromExtendedJSON = function (doc) {
|
|
37
39
|
return new BSONSymbol(doc.$symbol);
|
|
38
|
-
}
|
|
40
|
+
};
|
|
39
41
|
/** @internal */
|
|
40
|
-
[Symbol.for('nodejs.util.inspect.custom')]() {
|
|
42
|
+
BSONSymbol.prototype[Symbol.for('nodejs.util.inspect.custom')] = function () {
|
|
41
43
|
return this.inspect();
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
+
};
|
|
45
|
+
return BSONSymbol;
|
|
46
|
+
}());
|
|
44
47
|
exports.BSONSymbol = BSONSymbol;
|
|
45
48
|
Object.defineProperty(BSONSymbol.prototype, '_bsontype', { value: 'Symbol' });
|
|
46
49
|
//# sourceMappingURL=symbol.js.map
|
package/lib/symbol.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"symbol.js","sourceRoot":"","sources":["../src/symbol.ts"],"names":[],"mappings":";;;AAKA;;;GAGG;AACH
|
|
1
|
+
{"version":3,"file":"symbol.js","sourceRoot":"","sources":["../src/symbol.ts"],"names":[],"mappings":";;;AAKA;;;GAGG;AACH;IAIE;;OAEG;IACH,oBAAY,KAAa;QACvB,IAAI,CAAC,CAAC,IAAI,YAAY,UAAU,CAAC;YAAE,OAAO,IAAI,UAAU,CAAC,KAAK,CAAC,CAAC;QAEhE,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;IAED,uCAAuC;IACvC,4BAAO,GAAP;QACE,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;IAED,gBAAgB;IAChB,6BAAQ,GAAR;QACE,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;IAED,gBAAgB;IAChB,4BAAO,GAAP;QACE,OAAO,sBAAmB,IAAI,CAAC,KAAK,QAAI,CAAC;IAC3C,CAAC;IAED,gBAAgB;IAChB,2BAAM,GAAN;QACE,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;IAED,gBAAgB;IAChB,mCAAc,GAAd;QACE,OAAO,EAAE,OAAO,EAAE,IAAI,CAAC,KAAK,EAAE,CAAC;IACjC,CAAC;IAED,gBAAgB;IACT,2BAAgB,GAAvB,UAAwB,GAAuB;QAC7C,OAAO,IAAI,UAAU,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IACrC,CAAC;IAED,gBAAgB;IAChB,qBAAC,MAAM,CAAC,GAAG,CAAC,4BAA4B,CAAC,CAAC,GAA1C;QACE,OAAO,IAAI,CAAC,OAAO,EAAE,CAAC;IACxB,CAAC;IACH,iBAAC;AAAD,CAAC,AA/CD,IA+CC;AA/CY,gCAAU;AAiDvB,MAAM,CAAC,cAAc,CAAC,UAAU,CAAC,SAAS,EAAE,WAAW,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,CAAC"}
|
package/lib/timestamp.js
CHANGED
|
@@ -1,72 +1,93 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
extendStatics(d, b);
|
|
11
|
+
function __() { this.constructor = d; }
|
|
12
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
13
|
+
};
|
|
14
|
+
})();
|
|
2
15
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
16
|
exports.Timestamp = exports.LongWithoutOverridesClass = void 0;
|
|
4
|
-
|
|
17
|
+
var long_1 = require("./long");
|
|
5
18
|
/** @public */
|
|
6
19
|
exports.LongWithoutOverridesClass = long_1.Long;
|
|
7
20
|
/** @public */
|
|
8
|
-
|
|
9
|
-
|
|
21
|
+
var Timestamp = /** @class */ (function (_super) {
|
|
22
|
+
__extends(Timestamp, _super);
|
|
23
|
+
function Timestamp(low, high) {
|
|
24
|
+
var _this = this;
|
|
25
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
26
|
+
///@ts-expect-error
|
|
27
|
+
if (!(_this instanceof Timestamp))
|
|
28
|
+
return new Timestamp(low, high);
|
|
10
29
|
if (long_1.Long.isLong(low)) {
|
|
11
|
-
|
|
30
|
+
_this = _super.call(this, low.low, low.high, true) || this;
|
|
12
31
|
}
|
|
13
32
|
else {
|
|
14
|
-
|
|
33
|
+
_this = _super.call(this, low, high, true) || this;
|
|
15
34
|
}
|
|
16
|
-
Object.defineProperty(
|
|
35
|
+
Object.defineProperty(_this, '_bsontype', {
|
|
17
36
|
value: 'Timestamp',
|
|
18
37
|
writable: false,
|
|
19
38
|
configurable: false,
|
|
20
39
|
enumerable: false
|
|
21
40
|
});
|
|
41
|
+
return _this;
|
|
22
42
|
}
|
|
23
|
-
toJSON() {
|
|
43
|
+
Timestamp.prototype.toJSON = function () {
|
|
24
44
|
return {
|
|
25
45
|
$timestamp: this.toString()
|
|
26
46
|
};
|
|
27
|
-
}
|
|
47
|
+
};
|
|
28
48
|
/** Returns a Timestamp represented by the given (32-bit) integer value. */
|
|
29
|
-
|
|
49
|
+
Timestamp.fromInt = function (value) {
|
|
30
50
|
return new Timestamp(long_1.Long.fromInt(value, true));
|
|
31
|
-
}
|
|
51
|
+
};
|
|
32
52
|
/** Returns a Timestamp representing the given number value, provided that it is a finite number. Otherwise, zero is returned. */
|
|
33
|
-
|
|
53
|
+
Timestamp.fromNumber = function (value) {
|
|
34
54
|
return new Timestamp(long_1.Long.fromNumber(value, true));
|
|
35
|
-
}
|
|
55
|
+
};
|
|
36
56
|
/**
|
|
37
57
|
* Returns a Timestamp for the given high and low bits. Each is assumed to use 32 bits.
|
|
38
58
|
*
|
|
39
59
|
* @param lowBits - the low 32-bits.
|
|
40
60
|
* @param highBits - the high 32-bits.
|
|
41
61
|
*/
|
|
42
|
-
|
|
62
|
+
Timestamp.fromBits = function (lowBits, highBits) {
|
|
43
63
|
return new Timestamp(lowBits, highBits);
|
|
44
|
-
}
|
|
64
|
+
};
|
|
45
65
|
/**
|
|
46
66
|
* Returns a Timestamp from the given string, optionally using the given radix.
|
|
47
67
|
*
|
|
48
68
|
* @param str - the textual representation of the Timestamp.
|
|
49
69
|
* @param optRadix - the radix in which the text is written.
|
|
50
70
|
*/
|
|
51
|
-
|
|
71
|
+
Timestamp.fromString = function (str, optRadix) {
|
|
52
72
|
return new Timestamp(long_1.Long.fromString(str, true, optRadix));
|
|
53
|
-
}
|
|
73
|
+
};
|
|
54
74
|
/** @internal */
|
|
55
|
-
toExtendedJSON() {
|
|
75
|
+
Timestamp.prototype.toExtendedJSON = function () {
|
|
56
76
|
return { $timestamp: { t: this.high >>> 0, i: this.low >>> 0 } };
|
|
57
|
-
}
|
|
77
|
+
};
|
|
58
78
|
/** @internal */
|
|
59
|
-
|
|
79
|
+
Timestamp.fromExtendedJSON = function (doc) {
|
|
60
80
|
return new Timestamp(doc.$timestamp.i, doc.$timestamp.t);
|
|
61
|
-
}
|
|
81
|
+
};
|
|
62
82
|
/** @internal */
|
|
63
|
-
[Symbol.for('nodejs.util.inspect.custom')]() {
|
|
83
|
+
Timestamp.prototype[Symbol.for('nodejs.util.inspect.custom')] = function () {
|
|
64
84
|
return this.inspect();
|
|
65
|
-
}
|
|
66
|
-
inspect() {
|
|
67
|
-
return
|
|
68
|
-
}
|
|
69
|
-
|
|
85
|
+
};
|
|
86
|
+
Timestamp.prototype.inspect = function () {
|
|
87
|
+
return "new Timestamp(" + this.getLowBits().toString() + ", " + this.getHighBits().toString() + ")";
|
|
88
|
+
};
|
|
89
|
+
Timestamp.MAX_VALUE = long_1.Long.MAX_UNSIGNED_VALUE;
|
|
90
|
+
return Timestamp;
|
|
91
|
+
}(exports.LongWithoutOverridesClass));
|
|
70
92
|
exports.Timestamp = Timestamp;
|
|
71
|
-
Timestamp.MAX_VALUE = long_1.Long.MAX_UNSIGNED_VALUE;
|
|
72
93
|
//# sourceMappingURL=timestamp.js.map
|
package/lib/timestamp.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"timestamp.js","sourceRoot":"","sources":["../src/timestamp.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"timestamp.js","sourceRoot":"","sources":["../src/timestamp.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+BAA8B;AAQ9B,cAAc;AACD,QAAA,yBAAyB,GAA0B,WAAwC,CAAC;AAUzG,cAAc;AACd;IAA+B,6BAAyB;IAetD,mBAAY,GAAkB,EAAE,IAAa;QAA7C,iBAgBC;QAfC,6DAA6D;QAC7D,mBAAmB;QACnB,IAAI,CAAC,CAAC,KAAI,YAAY,SAAS,CAAC;YAAE,OAAO,IAAI,SAAS,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;QAElE,IAAI,WAAI,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE;YACpB,QAAA,kBAAM,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,SAAC;SAChC;aAAM;YACL,QAAA,kBAAM,GAAG,EAAE,IAAI,EAAE,IAAI,CAAC,SAAC;SACxB;QACD,MAAM,CAAC,cAAc,CAAC,KAAI,EAAE,WAAW,EAAE;YACvC,KAAK,EAAE,WAAW;YAClB,QAAQ,EAAE,KAAK;YACf,YAAY,EAAE,KAAK;YACnB,UAAU,EAAE,KAAK;SAClB,CAAC,CAAC;;IACL,CAAC;IAED,0BAAM,GAAN;QACE,OAAO;YACL,UAAU,EAAE,IAAI,CAAC,QAAQ,EAAE;SAC5B,CAAC;IACJ,CAAC;IAED,2EAA2E;IACpE,iBAAO,GAAd,UAAe,KAAa;QAC1B,OAAO,IAAI,SAAS,CAAC,WAAI,CAAC,OAAO,CAAC,KAA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,CAA+B,iCAAyB,GAuFvD;AAvFY,8BAAS"}
|
package/lib/uuid.js
CHANGED
|
@@ -5,7 +5,7 @@ exports.parseUUID = void 0;
|
|
|
5
5
|
* UUID regular expression pattern copied from `uuid` npm module.
|
|
6
6
|
* @see https://github.com/uuidjs/uuid/blob/master/src/regex.js
|
|
7
7
|
*/
|
|
8
|
-
|
|
8
|
+
var UUID_RX = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;
|
|
9
9
|
/**
|
|
10
10
|
* Parser function copied from `uuid` npm module.
|
|
11
11
|
* @see https://github.com/uuidjs/uuid/blob/master/src/parse.js
|
|
@@ -18,8 +18,8 @@ function parseUUID(uuid) {
|
|
|
18
18
|
if (!UUID_RX.test(uuid)) {
|
|
19
19
|
throw new TypeError('Invalid format for UUID: ' + uuid);
|
|
20
20
|
}
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
var v;
|
|
22
|
+
var arr = new Uint8Array(16);
|
|
23
23
|
// Parse ########-....-....-....-............
|
|
24
24
|
arr[0] = (v = parseInt(uuid.slice(0, 8), 16)) >>> 24;
|
|
25
25
|
arr[1] = (v >>> 16) & 0xff;
|
package/lib/uuid.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"uuid.js","sourceRoot":"","sources":["../src/uuid.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACH,
|
|
1
|
+
{"version":3,"file":"uuid.js","sourceRoot":"","sources":["../src/uuid.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACH,IAAM,OAAO,GAAG,qHAAqH,CAAC;AAOtI;;;;GAIG;AACH,SAAgB,SAAS,CAAC,IAAY;IACpC,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE;QAC5B,MAAM,IAAI,SAAS,CAAC,iDAAiD,GAAG,OAAO,IAAI,CAAC,CAAC;KACtF;IAED,IAA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K,CAAC,CAAC;IACtD,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC;IAElB,6CAA6C;IAC7C,0EAA0E;IAC1E,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,aAAa,CAAC,GAAG,IAAI,CAAC;IAC1E,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,GAAG,WAAW,CAAC,GAAG,IAAI,CAAC;IACnC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,CAAC,GAAG,IAAI,CAAC;IAC5B,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,CAAC,GAAG,IAAI,CAAC;IAC5B,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,GAAG,IAAI,CAAC;IAC3B,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC;IAEnB,OAAO,GAAG,CAAC;AACb,CAAC;AAxCD,8BAwCC"}
|
package/lib/validate_utf8.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.validateUtf8 = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
4
|
+
var FIRST_BIT = 0x80;
|
|
5
|
+
var FIRST_TWO_BITS = 0xc0;
|
|
6
|
+
var FIRST_THREE_BITS = 0xe0;
|
|
7
|
+
var FIRST_FOUR_BITS = 0xf0;
|
|
8
|
+
var FIRST_FIVE_BITS = 0xf8;
|
|
9
|
+
var TWO_BIT_CHAR = 0xc0;
|
|
10
|
+
var THREE_BIT_CHAR = 0xe0;
|
|
11
|
+
var FOUR_BIT_CHAR = 0xf0;
|
|
12
|
+
var CONTINUING_CHAR = 0x80;
|
|
13
13
|
/**
|
|
14
14
|
* Determines if the passed in bytes are valid utf8
|
|
15
15
|
* @param bytes - An array of 8-bit bytes. Must be indexable and have length property
|
|
@@ -17,9 +17,9 @@ const CONTINUING_CHAR = 0x80;
|
|
|
17
17
|
* @param end - The index to end validating
|
|
18
18
|
*/
|
|
19
19
|
function validateUtf8(bytes, start, end) {
|
|
20
|
-
|
|
21
|
-
for (
|
|
22
|
-
|
|
20
|
+
var continuation = 0;
|
|
21
|
+
for (var i = start; i < end; i += 1) {
|
|
22
|
+
var byte = bytes[i];
|
|
23
23
|
if (continuation) {
|
|
24
24
|
if ((byte & FIRST_TWO_BITS) !== CONTINUING_CHAR) {
|
|
25
25
|
return false;
|
package/lib/validate_utf8.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate_utf8.js","sourceRoot":"","sources":["../src/validate_utf8.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"validate_utf8.js","sourceRoot":"","sources":["../src/validate_utf8.ts"],"names":[],"mappings":";;;AAAA,IAAM,SAAS,GAAG,IAAI,CAAC;AACvB,IAAM,cAAc,GAAG,IAAI,CAAC;AAC5B,IAAM,gBAAgB,GAAG,IAAI,CAAC;AAC9B,IAAM,eAAe,GAAG,IAAI,CAAC;AAC7B,IAAM,eAAe,GAAG,IAAI,CAAC;AAE7B,IAAM,YAAY,GAAG,IAAI,CAAC;AAC1B,IAAM,cAAc,GAAG,IAAI,CAAC;AAC5B,IAAM,aAAa,GAAG,IAAI,CAAC;AAC3B,IAAM,eAAe,GAAG,IAAI,CAAC;AAE7B;;;;;GAKG;AACH,SAAgB,YAAY,CAC1B,KAAkC,EAClC,KAAa,EACb,GAAW;IAEX,IAAI,YAAY,GAAG,CAAC,CAAC;IAErB,KAAK,IAAI,CAAC,GAAG,KAAK,EAAE,CAAC,GAAG,GAAG,EAAE,CAAC,IAAI,CAAC,EAAE;QACnC,IAAM,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;QAEtB,IAAI,YAAY,EAAE;YAChB,IAAI,CAAC,IAAI,GAAG,cAAc,CAAC,KAAK,eAAe,EAAE;gBAC/C,OAAO,KAAK,CAAC;aACd;YACD,YAAY,IAAI,CAAC,CAAC;SACnB;aAAM,IAAI,IAAI,GAAG,SAAS,EAAE;YAC3B,IAAI,CAAC,IAAI,GAAG,gBAAgB,CAAC,KAAK,YAAY,EAAE;gBAC9C,YAAY,GAAG,CAAC,CAAC;aAClB;iBAAM,IAAI,CAAC,IAAI,GAAG,eAAe,CAAC,KAAK,cAAc,EAAE;gBACtD,YAAY,GAAG,CAAC,CAAC;aAClB;iBAAM,IAAI,CAAC,IAAI,GAAG,eAAe,CAAC,KAAK,aAAa,EAAE;gBACrD,YAAY,GAAG,CAAC,CAAC;aAClB;iBAAM;gBACL,OAAO,KAAK,CAAC;aACd;SACF;KACF;IAED,OAAO,CAAC,YAAY,CAAC;AACvB,CAAC;AA7BD,oCA6BC"}
|
package/package.json
CHANGED
package/src/binary.ts
CHANGED
|
@@ -50,15 +50,17 @@ export class Binary {
|
|
|
50
50
|
/** User BSON type */
|
|
51
51
|
static readonly SUBTYPE_USER_DEFINED = 128;
|
|
52
52
|
|
|
53
|
-
buffer
|
|
54
|
-
sub_type
|
|
55
|
-
position
|
|
53
|
+
buffer!: Buffer;
|
|
54
|
+
sub_type!: number;
|
|
55
|
+
position!: number;
|
|
56
56
|
|
|
57
57
|
/**
|
|
58
58
|
* @param buffer - a buffer object containing the binary data.
|
|
59
59
|
* @param subType - the option binary type.
|
|
60
60
|
*/
|
|
61
61
|
constructor(buffer?: string | BinarySequence, subType?: number) {
|
|
62
|
+
if (!(this instanceof Binary)) return new Binary(buffer, subType);
|
|
63
|
+
|
|
62
64
|
if (
|
|
63
65
|
!(buffer == null) &&
|
|
64
66
|
!(typeof buffer === 'string') &&
|
|
@@ -263,7 +265,7 @@ export class Binary {
|
|
|
263
265
|
|
|
264
266
|
inspect(): string {
|
|
265
267
|
const asBuffer = this.value(true);
|
|
266
|
-
return `Binary("${asBuffer.toString('hex')}", ${this.sub_type})`;
|
|
268
|
+
return `new Binary(Buffer.from("${asBuffer.toString('hex')}", "hex"), ${this.sub_type})`;
|
|
267
269
|
}
|
|
268
270
|
}
|
|
269
271
|
|
package/src/code.ts
CHANGED
|
@@ -13,13 +13,15 @@ export interface CodeExtended {
|
|
|
13
13
|
export class Code {
|
|
14
14
|
_bsontype!: 'Code';
|
|
15
15
|
|
|
16
|
-
code
|
|
16
|
+
code!: string | Function;
|
|
17
17
|
scope?: Document;
|
|
18
18
|
/**
|
|
19
19
|
* @param code - a string or function.
|
|
20
20
|
* @param scope - an optional scope for the function.
|
|
21
21
|
*/
|
|
22
22
|
constructor(code: string | Function, scope?: Document) {
|
|
23
|
+
if (!(this instanceof Code)) return new Code(code, scope);
|
|
24
|
+
|
|
23
25
|
this.code = code;
|
|
24
26
|
this.scope = scope;
|
|
25
27
|
}
|
|
@@ -50,7 +52,9 @@ export class Code {
|
|
|
50
52
|
|
|
51
53
|
inspect(): string {
|
|
52
54
|
const codeJson = this.toJSON();
|
|
53
|
-
return `Code("${codeJson.code}"${
|
|
55
|
+
return `new Code("${codeJson.code}"${
|
|
56
|
+
codeJson.scope ? `, ${JSON.stringify(codeJson.scope)}` : ''
|
|
57
|
+
})`;
|
|
54
58
|
}
|
|
55
59
|
}
|
|
56
60
|
|
package/src/db_ref.ts
CHANGED
|
@@ -22,10 +22,10 @@ export function isDBRefLike(value: unknown): value is DBRefLike {
|
|
|
22
22
|
export class DBRef {
|
|
23
23
|
_bsontype!: 'DBRef';
|
|
24
24
|
|
|
25
|
-
collection
|
|
26
|
-
oid
|
|
25
|
+
collection!: string;
|
|
26
|
+
oid!: ObjectId;
|
|
27
27
|
db?: string;
|
|
28
|
-
fields
|
|
28
|
+
fields!: Document;
|
|
29
29
|
|
|
30
30
|
/**
|
|
31
31
|
* @param collection - the collection name.
|
|
@@ -33,6 +33,8 @@ export class DBRef {
|
|
|
33
33
|
* @param db - optional db name, if omitted the reference is local to the current db.
|
|
34
34
|
*/
|
|
35
35
|
constructor(collection: string, oid: ObjectId, db?: string, fields?: Document) {
|
|
36
|
+
if (!(this instanceof DBRef)) return new DBRef(collection, oid, db, fields);
|
|
37
|
+
|
|
36
38
|
// check if namespace has been provided
|
|
37
39
|
const parts = collection.split('.');
|
|
38
40
|
if (parts.length === 2) {
|
|
@@ -108,7 +110,9 @@ export class DBRef {
|
|
|
108
110
|
// NOTE: if OID is an ObjectId class it will just print the oid string.
|
|
109
111
|
const oid =
|
|
110
112
|
this.oid === undefined || this.oid.toString === undefined ? this.oid : this.oid.toString();
|
|
111
|
-
return `DBRef("${this.namespace}", "${oid}"${
|
|
113
|
+
return `new DBRef("${this.namespace}", new ObjectId("${oid}")${
|
|
114
|
+
this.db ? `, "${this.db}"` : ''
|
|
115
|
+
})`;
|
|
112
116
|
}
|
|
113
117
|
}
|
|
114
118
|
|
package/src/decimal128.ts
CHANGED
|
@@ -165,10 +165,12 @@ export interface Decimal128Extended {
|
|
|
165
165
|
export class Decimal128 {
|
|
166
166
|
_bsontype!: 'Decimal128';
|
|
167
167
|
|
|
168
|
-
readonly bytes
|
|
168
|
+
readonly bytes!: Buffer;
|
|
169
169
|
|
|
170
170
|
/** @param bytes - a buffer containing the raw Decimal128 bytes in little endian order */
|
|
171
171
|
constructor(bytes: Buffer) {
|
|
172
|
+
if (!(this instanceof Decimal128)) return new Decimal128(bytes);
|
|
173
|
+
|
|
172
174
|
this.bytes = bytes;
|
|
173
175
|
}
|
|
174
176
|
|
|
@@ -794,7 +796,7 @@ export class Decimal128 {
|
|
|
794
796
|
}
|
|
795
797
|
|
|
796
798
|
inspect(): string {
|
|
797
|
-
return `Decimal128("${this.toString()}")`;
|
|
799
|
+
return `Decimal128.fromString("${this.toString()}")`;
|
|
798
800
|
}
|
|
799
801
|
}
|
|
800
802
|
|
package/src/double.ts
CHANGED
|
@@ -12,13 +12,15 @@ export interface DoubleExtended {
|
|
|
12
12
|
export class Double {
|
|
13
13
|
_bsontype!: 'Double';
|
|
14
14
|
|
|
15
|
-
value
|
|
15
|
+
value!: number;
|
|
16
16
|
/**
|
|
17
17
|
* Create a Double type
|
|
18
18
|
*
|
|
19
19
|
* @param value - the number we want to represent as a double.
|
|
20
20
|
*/
|
|
21
21
|
constructor(value: number) {
|
|
22
|
+
if (!(this instanceof Double)) return new Double(value);
|
|
23
|
+
|
|
22
24
|
if ((value as unknown) instanceof Number) {
|
|
23
25
|
value = value.valueOf();
|
|
24
26
|
}
|
|
@@ -78,7 +80,7 @@ export class Double {
|
|
|
78
80
|
|
|
79
81
|
inspect(): string {
|
|
80
82
|
const eJSON = this.toExtendedJSON() as DoubleExtended;
|
|
81
|
-
return `Double(${eJSON.$numberDouble})`;
|
|
83
|
+
return `new Double(${eJSON.$numberDouble})`;
|
|
82
84
|
}
|
|
83
85
|
}
|
|
84
86
|
|
package/src/int_32.ts
CHANGED
|
@@ -12,13 +12,15 @@ export interface Int32Extended {
|
|
|
12
12
|
export class Int32 {
|
|
13
13
|
_bsontype!: 'Int32';
|
|
14
14
|
|
|
15
|
-
value
|
|
15
|
+
value!: number;
|
|
16
16
|
/**
|
|
17
17
|
* Create an Int32 type
|
|
18
18
|
*
|
|
19
19
|
* @param value - the number we want to represent as an int32.
|
|
20
20
|
*/
|
|
21
21
|
constructor(value: number | string) {
|
|
22
|
+
if (!(this instanceof Int32)) return new Int32(value);
|
|
23
|
+
|
|
22
24
|
if ((value as unknown) instanceof Number) {
|
|
23
25
|
value = value.valueOf();
|
|
24
26
|
}
|
|
@@ -57,7 +59,7 @@ export class Int32 {
|
|
|
57
59
|
}
|
|
58
60
|
|
|
59
61
|
inspect(): string {
|
|
60
|
-
return `Int32(${this.valueOf()})`;
|
|
62
|
+
return `new Int32(${this.valueOf()})`;
|
|
61
63
|
}
|
|
62
64
|
}
|
|
63
65
|
|