bson 4.4.0 → 4.5.2

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.
Files changed (70) hide show
  1. package/bower.json +1 -1
  2. package/bson.d.ts +42 -14
  3. package/dist/bson.browser.esm.js +628 -2199
  4. package/dist/bson.browser.esm.js.map +1 -1
  5. package/dist/bson.browser.umd.js +681 -2254
  6. package/dist/bson.browser.umd.js.map +1 -1
  7. package/dist/bson.bundle.js +681 -2254
  8. package/dist/bson.bundle.js.map +1 -1
  9. package/dist/bson.esm.js +622 -2197
  10. package/dist/bson.esm.js.map +1 -1
  11. package/lib/binary.js +0 -3
  12. package/lib/binary.js.map +1 -1
  13. package/lib/bson.js +1 -1
  14. package/lib/bson.js.map +1 -1
  15. package/lib/code.js +0 -1
  16. package/lib/code.js.map +1 -1
  17. package/lib/db_ref.js +4 -2
  18. package/lib/db_ref.js.map +1 -1
  19. package/lib/decimal128.js +4 -49
  20. package/lib/decimal128.js.map +1 -1
  21. package/lib/double.js +3 -1
  22. package/lib/double.js.map +1 -1
  23. package/lib/extended_json.js +3 -3
  24. package/lib/extended_json.js.map +1 -1
  25. package/lib/int_32.js +3 -1
  26. package/lib/int_32.js.map +1 -1
  27. package/lib/long.js.map +1 -1
  28. package/lib/map.js +3 -15
  29. package/lib/map.js.map +1 -1
  30. package/lib/objectid.js +1 -5
  31. package/lib/objectid.js.map +1 -1
  32. package/lib/parser/deserializer.js +15 -12
  33. package/lib/parser/deserializer.js.map +1 -1
  34. package/lib/parser/serializer.js +7 -3
  35. package/lib/parser/serializer.js.map +1 -1
  36. package/lib/parser/utils.js +8 -8
  37. package/lib/parser/utils.js.map +1 -1
  38. package/lib/regexp.js +1 -3
  39. package/lib/regexp.js.map +1 -1
  40. package/lib/symbol.js +0 -2
  41. package/lib/symbol.js.map +1 -1
  42. package/lib/timestamp.js +6 -2
  43. package/lib/timestamp.js.map +1 -1
  44. package/lib/utils/global.js +18 -0
  45. package/lib/utils/global.js.map +1 -0
  46. package/lib/uuid.js +2 -3
  47. package/lib/uuid.js.map +1 -1
  48. package/lib/uuid_utils.js.map +1 -1
  49. package/package.json +22 -9
  50. package/src/binary.ts +1 -4
  51. package/src/bson.ts +1 -1
  52. package/src/code.ts +0 -1
  53. package/src/db_ref.ts +6 -2
  54. package/src/decimal128.ts +4 -49
  55. package/src/double.ts +4 -1
  56. package/src/extended_json.ts +6 -6
  57. package/src/int_32.ts +4 -1
  58. package/src/long.ts +2 -2
  59. package/src/map.ts +5 -25
  60. package/src/objectid.ts +1 -5
  61. package/src/parser/deserializer.ts +23 -16
  62. package/src/parser/serializer.ts +7 -3
  63. package/src/parser/utils.ts +9 -11
  64. package/src/regexp.ts +2 -4
  65. package/src/symbol.ts +0 -2
  66. package/src/timestamp.ts +15 -7
  67. package/src/utils/global.ts +22 -0
  68. package/src/uuid.ts +2 -3
  69. package/src/uuid_utils.ts +2 -1
  70. package/HISTORY.md +0 -505
@@ -1,12 +1,6 @@
1
1
  var BSON = (function (exports) {
2
2
  'use strict';
3
3
 
4
- var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
5
-
6
- function unwrapExports (x) {
7
- return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
8
- }
9
-
10
4
  function createCommonjsModule(fn, module) {
11
5
  return module = { exports: {} }, fn(module, module.exports), module.exports;
12
6
  }
@@ -17,11 +11,11 @@ var BSON = (function (exports) {
17
11
  var lookup = [];
18
12
  var revLookup = [];
19
13
  var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array;
20
- var code$1 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
14
+ var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
21
15
 
22
- for (var i = 0, len = code$1.length; i < len; ++i) {
23
- lookup[i] = code$1[i];
24
- revLookup[code$1.charCodeAt(i)] = i;
16
+ for (var i = 0, len = code.length; i < len; ++i) {
17
+ lookup[i] = code[i];
18
+ revLookup[code.charCodeAt(i)] = i;
25
19
  } // Support decoding URL-safe base64 strings, as Node.js does.
26
20
  // See: https://en.wikipedia.org/wiki/Base64#URL_applications
27
21
 
@@ -230,7 +224,7 @@ var BSON = (function (exports) {
230
224
  write: write
231
225
  };
232
226
 
233
- var buffer = createCommonjsModule(function (module, exports) {
227
+ var buffer$1 = createCommonjsModule(function (module, exports) {
234
228
 
235
229
  var customInspectSymbol = typeof Symbol === 'function' && typeof Symbol['for'] === 'function' ? // eslint-disable-line dot-notation
236
230
  Symbol['for']('nodejs.util.inspect.custom') // eslint-disable-line dot-notation
@@ -2035,569 +2029,25 @@ var BSON = (function (exports) {
2035
2029
  return table;
2036
2030
  }();
2037
2031
  });
2038
- buffer.Buffer;
2039
- buffer.SlowBuffer;
2040
- buffer.INSPECT_MAX_BYTES;
2041
- buffer.kMaxLength;
2042
-
2043
- var require$$0 = {};
2044
-
2045
- var inherits;
2046
-
2047
- if (typeof Object.create === 'function') {
2048
- inherits = function inherits(ctor, superCtor) {
2049
- // implementation from standard node.js 'util' module
2050
- ctor.super_ = superCtor;
2051
- ctor.prototype = Object.create(superCtor.prototype, {
2052
- constructor: {
2053
- value: ctor,
2054
- enumerable: false,
2055
- writable: true,
2056
- configurable: true
2057
- }
2058
- });
2059
- };
2060
- } else {
2061
- inherits = function inherits(ctor, superCtor) {
2062
- ctor.super_ = superCtor;
2063
-
2064
- var TempCtor = function TempCtor() {};
2065
-
2066
- TempCtor.prototype = superCtor.prototype;
2067
- ctor.prototype = new TempCtor();
2068
- ctor.prototype.constructor = ctor;
2069
- };
2070
- }
2071
-
2072
- var inherits$1 = inherits;
2073
-
2074
- // Copyright Joyent, Inc. and other Node contributors.
2075
- var formatRegExp = /%[sdj%]/g;
2076
- function format(f) {
2077
- if (!isString(f)) {
2078
- var objects = [];
2079
-
2080
- for (var i = 0; i < arguments.length; i++) {
2081
- objects.push(inspect(arguments[i]));
2082
- }
2083
-
2084
- return objects.join(' ');
2085
- }
2086
-
2087
- var i = 1;
2088
- var args = arguments;
2089
- var len = args.length;
2090
- var str = String(f).replace(formatRegExp, function (x) {
2091
- if (x === '%%') return '%';
2092
- if (i >= len) return x;
2093
-
2094
- switch (x) {
2095
- case '%s':
2096
- return String(args[i++]);
2097
-
2098
- case '%d':
2099
- return Number(args[i++]);
2100
-
2101
- case '%j':
2102
- try {
2103
- return JSON.stringify(args[i++]);
2104
- } catch (_) {
2105
- return '[Circular]';
2106
- }
2107
-
2108
- default:
2109
- return x;
2110
- }
2111
- });
2112
-
2113
- for (var x = args[i]; i < len; x = args[++i]) {
2114
- if (isNull(x) || !isObject(x)) {
2115
- str += ' ' + x;
2116
- } else {
2117
- str += ' ' + inspect(x);
2118
- }
2119
- }
2120
-
2121
- return str;
2122
- }
2123
- // Returns a modified function which warns once by default.
2124
- // If --no-deprecation is set, then it is a no-op.
2125
-
2126
- function deprecate(fn, msg) {
2127
- // Allow for deprecating things in the process of starting up.
2128
- if (isUndefined(global.process)) {
2129
- return function () {
2130
- return deprecate(fn, msg).apply(this, arguments);
2131
- };
2132
- }
2133
-
2134
- var warned = false;
2135
-
2136
- function deprecated() {
2137
- if (!warned) {
2138
- {
2139
- console.error(msg);
2140
- }
2141
-
2142
- warned = true;
2143
- }
2144
-
2145
- return fn.apply(this, arguments);
2146
- }
2147
-
2148
- return deprecated;
2149
- }
2150
- var debugs = {};
2151
- var debugEnviron;
2152
- function debuglog(set) {
2153
- if (isUndefined(debugEnviron)) debugEnviron = '';
2154
- set = set.toUpperCase();
2155
-
2156
- if (!debugs[set]) {
2157
- if (new RegExp('\\b' + set + '\\b', 'i').test(debugEnviron)) {
2158
- var pid = 0;
2159
-
2160
- debugs[set] = function () {
2161
- var msg = format.apply(null, arguments);
2162
- console.error('%s %d: %s', set, pid, msg);
2163
- };
2164
- } else {
2165
- debugs[set] = function () {};
2166
- }
2167
- }
2168
-
2169
- return debugs[set];
2170
- }
2171
- /**
2172
- * Echos the value of a value. Trys to print the value out
2173
- * in the best way possible given the different types.
2174
- *
2175
- * @param {Object} obj The object to print out.
2176
- * @param {Object} opts Optional options object that alters the output.
2177
- */
2178
-
2179
- /* legacy: obj, showHidden, depth, colors*/
2180
-
2181
- function inspect(obj, opts) {
2182
- // default options
2183
- var ctx = {
2184
- seen: [],
2185
- stylize: stylizeNoColor
2186
- }; // legacy...
2187
-
2188
- if (arguments.length >= 3) ctx.depth = arguments[2];
2189
- if (arguments.length >= 4) ctx.colors = arguments[3];
2190
-
2191
- if (isBoolean(opts)) {
2192
- // legacy...
2193
- ctx.showHidden = opts;
2194
- } else if (opts) {
2195
- // got an "options" object
2196
- _extend(ctx, opts);
2197
- } // set default options
2198
-
2199
-
2200
- if (isUndefined(ctx.showHidden)) ctx.showHidden = false;
2201
- if (isUndefined(ctx.depth)) ctx.depth = 2;
2202
- if (isUndefined(ctx.colors)) ctx.colors = false;
2203
- if (isUndefined(ctx.customInspect)) ctx.customInspect = true;
2204
- if (ctx.colors) ctx.stylize = stylizeWithColor;
2205
- return formatValue(ctx, obj, ctx.depth);
2206
- } // http://en.wikipedia.org/wiki/ANSI_escape_code#graphics
2207
-
2208
- inspect.colors = {
2209
- 'bold': [1, 22],
2210
- 'italic': [3, 23],
2211
- 'underline': [4, 24],
2212
- 'inverse': [7, 27],
2213
- 'white': [37, 39],
2214
- 'grey': [90, 39],
2215
- 'black': [30, 39],
2216
- 'blue': [34, 39],
2217
- 'cyan': [36, 39],
2218
- 'green': [32, 39],
2219
- 'magenta': [35, 39],
2220
- 'red': [31, 39],
2221
- 'yellow': [33, 39]
2222
- }; // Don't use 'blue' not visible on cmd.exe
2223
-
2224
- inspect.styles = {
2225
- 'special': 'cyan',
2226
- 'number': 'yellow',
2227
- 'boolean': 'yellow',
2228
- 'undefined': 'grey',
2229
- 'null': 'bold',
2230
- 'string': 'green',
2231
- 'date': 'magenta',
2232
- // "name": intentionally not styling
2233
- 'regexp': 'red'
2234
- };
2235
-
2236
- function stylizeWithColor(str, styleType) {
2237
- var style = inspect.styles[styleType];
2238
-
2239
- if (style) {
2240
- return "\x1B[" + inspect.colors[style][0] + 'm' + str + "\x1B[" + inspect.colors[style][1] + 'm';
2241
- } else {
2242
- return str;
2243
- }
2244
- }
2245
-
2246
- function stylizeNoColor(str, styleType) {
2247
- return str;
2248
- }
2249
-
2250
- function arrayToHash(array) {
2251
- var hash = {};
2252
- array.forEach(function (val, idx) {
2253
- hash[val] = true;
2254
- });
2255
- return hash;
2256
- }
2257
-
2258
- function formatValue(ctx, value, recurseTimes) {
2259
- // Provide a hook for user-specified inspect functions.
2260
- // Check that value is an object with an inspect function on it
2261
- if (ctx.customInspect && value && isFunction(value.inspect) && // Filter out the util module, it's inspect function is special
2262
- value.inspect !== inspect && // Also filter out any prototype objects using the circular check.
2263
- !(value.constructor && value.constructor.prototype === value)) {
2264
- var ret = value.inspect(recurseTimes, ctx);
2265
-
2266
- if (!isString(ret)) {
2267
- ret = formatValue(ctx, ret, recurseTimes);
2268
- }
2269
-
2270
- return ret;
2271
- } // Primitive types cannot have properties
2272
-
2273
-
2274
- var primitive = formatPrimitive(ctx, value);
2275
-
2276
- if (primitive) {
2277
- return primitive;
2278
- } // Look up the keys of the object.
2279
-
2280
-
2281
- var keys = Object.keys(value);
2282
- var visibleKeys = arrayToHash(keys);
2283
-
2284
- if (ctx.showHidden) {
2285
- keys = Object.getOwnPropertyNames(value);
2286
- } // IE doesn't make error fields non-enumerable
2287
- // http://msdn.microsoft.com/en-us/library/ie/dww52sbt(v=vs.94).aspx
2288
-
2289
-
2290
- if (isError(value) && (keys.indexOf('message') >= 0 || keys.indexOf('description') >= 0)) {
2291
- return formatError(value);
2292
- } // Some type of object without properties can be shortcutted.
2293
-
2294
-
2295
- if (keys.length === 0) {
2296
- if (isFunction(value)) {
2297
- var name = value.name ? ': ' + value.name : '';
2298
- return ctx.stylize('[Function' + name + ']', 'special');
2299
- }
2300
-
2301
- if (isRegExp(value)) {
2302
- return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
2303
- }
2304
-
2305
- if (isDate(value)) {
2306
- return ctx.stylize(Date.prototype.toString.call(value), 'date');
2307
- }
2308
-
2309
- if (isError(value)) {
2310
- return formatError(value);
2311
- }
2312
- }
2313
-
2314
- var base = '',
2315
- array = false,
2316
- braces = ['{', '}']; // Make Array say that they are Array
2317
-
2318
- if (isArray(value)) {
2319
- array = true;
2320
- braces = ['[', ']'];
2321
- } // Make functions say that they are functions
2322
-
2323
-
2324
- if (isFunction(value)) {
2325
- var n = value.name ? ': ' + value.name : '';
2326
- base = ' [Function' + n + ']';
2327
- } // Make RegExps say that they are RegExps
2328
-
2329
-
2330
- if (isRegExp(value)) {
2331
- base = ' ' + RegExp.prototype.toString.call(value);
2332
- } // Make dates with properties first say the date
2333
-
2334
-
2335
- if (isDate(value)) {
2336
- base = ' ' + Date.prototype.toUTCString.call(value);
2337
- } // Make error with message first say the error
2338
-
2339
-
2340
- if (isError(value)) {
2341
- base = ' ' + formatError(value);
2342
- }
2343
-
2344
- if (keys.length === 0 && (!array || value.length == 0)) {
2345
- return braces[0] + base + braces[1];
2346
- }
2347
-
2348
- if (recurseTimes < 0) {
2349
- if (isRegExp(value)) {
2350
- return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
2351
- } else {
2352
- return ctx.stylize('[Object]', 'special');
2353
- }
2354
- }
2355
-
2356
- ctx.seen.push(value);
2357
- var output;
2358
-
2359
- if (array) {
2360
- output = formatArray(ctx, value, recurseTimes, visibleKeys, keys);
2361
- } else {
2362
- output = keys.map(function (key) {
2363
- return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array);
2364
- });
2365
- }
2366
-
2367
- ctx.seen.pop();
2368
- return reduceToSingleString(output, base, braces);
2369
- }
2370
-
2371
- function formatPrimitive(ctx, value) {
2372
- if (isUndefined(value)) return ctx.stylize('undefined', 'undefined');
2373
-
2374
- if (isString(value)) {
2375
- var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '').replace(/'/g, "\\'").replace(/\\"/g, '"') + '\'';
2376
- return ctx.stylize(simple, 'string');
2377
- }
2378
-
2379
- if (isNumber(value)) return ctx.stylize('' + value, 'number');
2380
- if (isBoolean(value)) return ctx.stylize('' + value, 'boolean'); // For some reason typeof null is "object", so special case here.
2381
-
2382
- if (isNull(value)) return ctx.stylize('null', 'null');
2383
- }
2384
-
2385
- function formatError(value) {
2386
- return '[' + Error.prototype.toString.call(value) + ']';
2387
- }
2388
-
2389
- function formatArray(ctx, value, recurseTimes, visibleKeys, keys) {
2390
- var output = [];
2391
-
2392
- for (var i = 0, l = value.length; i < l; ++i) {
2393
- if (hasOwnProperty(value, String(i))) {
2394
- output.push(formatProperty(ctx, value, recurseTimes, visibleKeys, String(i), true));
2395
- } else {
2396
- output.push('');
2397
- }
2398
- }
2399
-
2400
- keys.forEach(function (key) {
2401
- if (!key.match(/^\d+$/)) {
2402
- output.push(formatProperty(ctx, value, recurseTimes, visibleKeys, key, true));
2403
- }
2404
- });
2405
- return output;
2406
- }
2407
-
2408
- function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) {
2409
- var name, str, desc;
2410
- desc = Object.getOwnPropertyDescriptor(value, key) || {
2411
- value: value[key]
2412
- };
2413
-
2414
- if (desc.get) {
2415
- if (desc.set) {
2416
- str = ctx.stylize('[Getter/Setter]', 'special');
2417
- } else {
2418
- str = ctx.stylize('[Getter]', 'special');
2419
- }
2420
- } else {
2421
- if (desc.set) {
2422
- str = ctx.stylize('[Setter]', 'special');
2423
- }
2424
- }
2425
-
2426
- if (!hasOwnProperty(visibleKeys, key)) {
2427
- name = '[' + key + ']';
2428
- }
2429
-
2430
- if (!str) {
2431
- if (ctx.seen.indexOf(desc.value) < 0) {
2432
- if (isNull(recurseTimes)) {
2433
- str = formatValue(ctx, desc.value, null);
2434
- } else {
2435
- str = formatValue(ctx, desc.value, recurseTimes - 1);
2436
- }
2437
-
2438
- if (str.indexOf('\n') > -1) {
2439
- if (array) {
2440
- str = str.split('\n').map(function (line) {
2441
- return ' ' + line;
2442
- }).join('\n').substr(2);
2443
- } else {
2444
- str = '\n' + str.split('\n').map(function (line) {
2445
- return ' ' + line;
2446
- }).join('\n');
2447
- }
2448
- }
2449
- } else {
2450
- str = ctx.stylize('[Circular]', 'special');
2451
- }
2452
- }
2453
-
2454
- if (isUndefined(name)) {
2455
- if (array && key.match(/^\d+$/)) {
2456
- return str;
2457
- }
2458
-
2459
- name = JSON.stringify('' + key);
2460
-
2461
- if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) {
2462
- name = name.substr(1, name.length - 2);
2463
- name = ctx.stylize(name, 'name');
2464
- } else {
2465
- name = name.replace(/'/g, "\\'").replace(/\\"/g, '"').replace(/(^"|"$)/g, "'");
2466
- name = ctx.stylize(name, 'string');
2467
- }
2468
- }
2469
-
2470
- return name + ': ' + str;
2471
- }
2472
-
2473
- function reduceToSingleString(output, base, braces) {
2474
- var length = output.reduce(function (prev, cur) {
2475
- if (cur.indexOf('\n') >= 0) ;
2476
- return prev + cur.replace(/\u001b\[\d\d?m/g, '').length + 1;
2477
- }, 0);
2478
-
2479
- if (length > 60) {
2480
- return braces[0] + (base === '' ? '' : base + '\n ') + ' ' + output.join(',\n ') + ' ' + braces[1];
2481
- }
2482
-
2483
- return braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1];
2484
- } // NOTE: These type checking functions intentionally don't use `instanceof`
2485
- // because it is fragile and can be easily faked with `Object.create()`.
2486
-
2487
-
2488
- function isArray(ar) {
2489
- return Array.isArray(ar);
2490
- }
2491
- function isBoolean(arg) {
2492
- return typeof arg === 'boolean';
2493
- }
2494
- function isNull(arg) {
2495
- return arg === null;
2496
- }
2497
- function isNullOrUndefined(arg) {
2498
- return arg == null;
2499
- }
2500
- function isNumber(arg) {
2501
- return typeof arg === 'number';
2502
- }
2503
- function isString(arg) {
2504
- return typeof arg === 'string';
2505
- }
2506
- function isSymbol(arg) {
2507
- return babelHelpers["typeof"](arg) === 'symbol';
2508
- }
2509
- function isUndefined(arg) {
2510
- return arg === void 0;
2511
- }
2512
- function isRegExp(re) {
2513
- return isObject(re) && objectToString(re) === '[object RegExp]';
2514
- }
2515
- function isObject(arg) {
2516
- return babelHelpers["typeof"](arg) === 'object' && arg !== null;
2517
- }
2518
- function isDate(d) {
2519
- return isObject(d) && objectToString(d) === '[object Date]';
2520
- }
2521
- function isError(e) {
2522
- return isObject(e) && (objectToString(e) === '[object Error]' || e instanceof Error);
2523
- }
2524
- function isFunction(arg) {
2525
- return typeof arg === 'function';
2526
- }
2527
- function isPrimitive(arg) {
2528
- return arg === null || typeof arg === 'boolean' || typeof arg === 'number' || typeof arg === 'string' || babelHelpers["typeof"](arg) === 'symbol' || // ES6 symbol
2529
- typeof arg === 'undefined';
2530
- }
2531
- function isBuffer(maybeBuf) {
2532
- return Buffer.isBuffer(maybeBuf);
2533
- }
2534
-
2535
- function objectToString(o) {
2536
- return Object.prototype.toString.call(o);
2537
- }
2538
-
2539
- function pad(n) {
2540
- return n < 10 ? '0' + n.toString(10) : n.toString(10);
2541
- }
2542
-
2543
- var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']; // 26 Feb 16:19:34
2544
-
2545
- function timestamp$1() {
2546
- var d = new Date();
2547
- var time = [pad(d.getHours()), pad(d.getMinutes()), pad(d.getSeconds())].join(':');
2548
- return [d.getDate(), months[d.getMonth()], time].join(' ');
2549
- } // log is just a thin wrapper to console.log that prepends a timestamp
2550
-
2551
-
2552
- function log() {
2553
- console.log('%s - %s', timestamp$1(), format.apply(null, arguments));
2554
- }
2555
- function _extend(origin, add) {
2556
- // Don't do anything if add isn't an object
2557
- if (!add || !isObject(add)) return origin;
2558
- var keys = Object.keys(add);
2559
- var i = keys.length;
2560
-
2561
- while (i--) {
2562
- origin[keys[i]] = add[keys[i]];
2563
- }
2032
+ var buffer_1 = buffer$1.Buffer;
2033
+ buffer$1.SlowBuffer;
2034
+ buffer$1.INSPECT_MAX_BYTES;
2035
+ buffer$1.kMaxLength;
2564
2036
 
2565
- return origin;
2037
+ function checkForMath(potentialGlobal) {
2038
+ // eslint-disable-next-line eqeqeq
2039
+ return potentialGlobal && potentialGlobal.Math == Math && potentialGlobal;
2566
2040
  }
2567
-
2568
- function hasOwnProperty(obj, prop) {
2569
- return Object.prototype.hasOwnProperty.call(obj, prop);
2041
+ // https://github.com/zloirock/core-js/issues/86#issuecomment-115759028
2042
+ function getGlobal() {
2043
+ // eslint-disable-next-line no-undef
2044
+ return (checkForMath(typeof globalThis === 'object' && globalThis) ||
2045
+ checkForMath(typeof window === 'object' && window) ||
2046
+ checkForMath(typeof self === 'object' && self) ||
2047
+ checkForMath(typeof global === 'object' && global) ||
2048
+ Function('return this')());
2570
2049
  }
2571
2050
 
2572
- var require$$1 = {
2573
- inherits: inherits$1,
2574
- _extend: _extend,
2575
- log: log,
2576
- isBuffer: isBuffer,
2577
- isPrimitive: isPrimitive,
2578
- isFunction: isFunction,
2579
- isError: isError,
2580
- isDate: isDate,
2581
- isObject: isObject,
2582
- isRegExp: isRegExp,
2583
- isUndefined: isUndefined,
2584
- isSymbol: isSymbol,
2585
- isString: isString,
2586
- isNumber: isNumber,
2587
- isNullOrUndefined: isNullOrUndefined,
2588
- isNull: isNull,
2589
- isBoolean: isBoolean,
2590
- isArray: isArray,
2591
- inspect: inspect,
2592
- deprecate: deprecate,
2593
- format: format,
2594
- debuglog: debuglog
2595
- };
2596
-
2597
- var utils = createCommonjsModule(function (module, exports) {
2598
- Object.defineProperty(exports, "__esModule", { value: true });
2599
- exports.deprecate = exports.isObjectLike = exports.isDate = exports.haveBuffer = exports.isMap = exports.isRegExp = exports.isBigUInt64Array = exports.isBigInt64Array = exports.isUint8Array = exports.isAnyArrayBuffer = exports.randomBytes = exports.normalizedFunctionString = void 0;
2600
-
2601
2051
  /**
2602
2052
  * Normalizes our expected stringified form of a function across versions of node
2603
2053
  * @param fn - The function to stringify
@@ -2605,14 +2055,16 @@ var BSON = (function (exports) {
2605
2055
  function normalizedFunctionString(fn) {
2606
2056
  return fn.toString().replace('function(', 'function (');
2607
2057
  }
2608
- exports.normalizedFunctionString = normalizedFunctionString;
2609
- var isReactNative = typeof commonjsGlobal.navigator === 'object' && commonjsGlobal.navigator.product === 'ReactNative';
2610
- var insecureWarning = isReactNative
2611
- ? 'BSON: For React Native please polyfill crypto.getRandomValues, e.g. using: https://www.npmjs.com/package/react-native-get-random-values.'
2612
- : 'BSON: No cryptographic implementation for random bytes present, falling back to a less secure implementation.';
2058
+ function isReactNative() {
2059
+ var g = getGlobal();
2060
+ return typeof g.navigator === 'object' && g.navigator.product === 'ReactNative';
2061
+ }
2613
2062
  var insecureRandomBytes = function insecureRandomBytes(size) {
2063
+ var insecureWarning = isReactNative()
2064
+ ? 'BSON: For React Native please polyfill crypto.getRandomValues, e.g. using: https://www.npmjs.com/package/react-native-get-random-values.'
2065
+ : 'BSON: No cryptographic implementation for random bytes present, falling back to a less secure implementation.';
2614
2066
  console.warn(insecureWarning);
2615
- var result = buffer.Buffer.alloc(size);
2067
+ var result = buffer_1.alloc(size);
2616
2068
  for (var i = 0; i < size; ++i)
2617
2069
  result[i] = Math.floor(Math.random() * 256);
2618
2070
  return result;
@@ -2622,17 +2074,17 @@ var BSON = (function (exports) {
2622
2074
  // browser crypto implementation(s)
2623
2075
  var target_1 = window.crypto || window.msCrypto; // allow for IE11
2624
2076
  if (target_1 && target_1.getRandomValues) {
2625
- return function (size) { return target_1.getRandomValues(buffer.Buffer.alloc(size)); };
2077
+ return function (size) { return target_1.getRandomValues(buffer_1.alloc(size)); };
2626
2078
  }
2627
2079
  }
2628
- if (typeof commonjsGlobal !== 'undefined' && commonjsGlobal.crypto && commonjsGlobal.crypto.getRandomValues) {
2080
+ if (typeof global !== 'undefined' && global.crypto && global.crypto.getRandomValues) {
2629
2081
  // allow for RN packages such as https://www.npmjs.com/package/react-native-get-random-values to populate global
2630
- return function (size) { return commonjsGlobal.crypto.getRandomValues(buffer.Buffer.alloc(size)); };
2082
+ return function (size) { return global.crypto.getRandomValues(buffer_1.alloc(size)); };
2631
2083
  }
2632
2084
  var requiredRandomBytes;
2633
2085
  try {
2634
2086
  // eslint-disable-next-line @typescript-eslint/no-var-requires
2635
- requiredRandomBytes = require$$0.randomBytes;
2087
+ requiredRandomBytes = require('crypto').randomBytes;
2636
2088
  }
2637
2089
  catch (e) {
2638
2090
  // keep the fallback
@@ -2640,41 +2092,29 @@ var BSON = (function (exports) {
2640
2092
  // NOTE: in transpiled cases the above require might return null/undefined
2641
2093
  return requiredRandomBytes || insecureRandomBytes;
2642
2094
  };
2643
- exports.randomBytes = detectRandomBytes();
2095
+ var randomBytes = detectRandomBytes();
2644
2096
  function isAnyArrayBuffer(value) {
2645
2097
  return ['[object ArrayBuffer]', '[object SharedArrayBuffer]'].includes(Object.prototype.toString.call(value));
2646
2098
  }
2647
- exports.isAnyArrayBuffer = isAnyArrayBuffer;
2648
2099
  function isUint8Array(value) {
2649
2100
  return Object.prototype.toString.call(value) === '[object Uint8Array]';
2650
2101
  }
2651
- exports.isUint8Array = isUint8Array;
2652
2102
  function isBigInt64Array(value) {
2653
2103
  return Object.prototype.toString.call(value) === '[object BigInt64Array]';
2654
2104
  }
2655
- exports.isBigInt64Array = isBigInt64Array;
2656
2105
  function isBigUInt64Array(value) {
2657
2106
  return Object.prototype.toString.call(value) === '[object BigUint64Array]';
2658
2107
  }
2659
- exports.isBigUInt64Array = isBigUInt64Array;
2660
2108
  function isRegExp(d) {
2661
2109
  return Object.prototype.toString.call(d) === '[object RegExp]';
2662
2110
  }
2663
- exports.isRegExp = isRegExp;
2664
2111
  function isMap(d) {
2665
2112
  return Object.prototype.toString.call(d) === '[object Map]';
2666
2113
  }
2667
- exports.isMap = isMap;
2668
- /** Call to check if your environment has `Buffer` */
2669
- function haveBuffer() {
2670
- return typeof commonjsGlobal !== 'undefined' && typeof commonjsGlobal.Buffer !== 'undefined';
2671
- }
2672
- exports.haveBuffer = haveBuffer;
2673
2114
  // To ensure that 0.4 of node works correctly
2674
2115
  function isDate(d) {
2675
2116
  return isObjectLike(d) && Object.prototype.toString.call(d) === '[object Date]';
2676
2117
  }
2677
- exports.isDate = isDate;
2678
2118
  /**
2679
2119
  * @internal
2680
2120
  * this is to solve the `'someKey' in x` problem where x is unknown.
@@ -2683,12 +2123,7 @@ var BSON = (function (exports) {
2683
2123
  function isObjectLike(candidate) {
2684
2124
  return typeof candidate === 'object' && candidate !== null;
2685
2125
  }
2686
- exports.isObjectLike = isObjectLike;
2687
2126
  function deprecate(fn, message) {
2688
- if (typeof window === 'undefined' && typeof self === 'undefined') {
2689
- // eslint-disable-next-line @typescript-eslint/no-var-requires
2690
- return require$$1.deprecate(fn, message);
2691
- }
2692
2127
  var warned = false;
2693
2128
  function deprecated() {
2694
2129
  var args = [];
@@ -2703,28 +2138,6 @@ var BSON = (function (exports) {
2703
2138
  }
2704
2139
  return deprecated;
2705
2140
  }
2706
- exports.deprecate = deprecate;
2707
- //# sourceMappingURL=utils.js.map
2708
- });
2709
-
2710
- unwrapExports(utils);
2711
- utils.deprecate;
2712
- utils.isObjectLike;
2713
- utils.isDate;
2714
- utils.haveBuffer;
2715
- utils.isMap;
2716
- utils.isRegExp;
2717
- utils.isBigUInt64Array;
2718
- utils.isBigInt64Array;
2719
- utils.isUint8Array;
2720
- utils.isAnyArrayBuffer;
2721
- utils.randomBytes;
2722
- utils.normalizedFunctionString;
2723
-
2724
- var ensure_buffer = createCommonjsModule(function (module, exports) {
2725
- Object.defineProperty(exports, "__esModule", { value: true });
2726
- exports.ensureBuffer = void 0;
2727
-
2728
2141
 
2729
2142
  /**
2730
2143
  * Makes sure that, if a Uint8Array is passed in, it is wrapped in a Buffer.
@@ -2736,38 +2149,26 @@ var BSON = (function (exports) {
2736
2149
  */
2737
2150
  function ensureBuffer(potentialBuffer) {
2738
2151
  if (ArrayBuffer.isView(potentialBuffer)) {
2739
- return buffer.Buffer.from(potentialBuffer.buffer, potentialBuffer.byteOffset, potentialBuffer.byteLength);
2152
+ return buffer_1.from(potentialBuffer.buffer, potentialBuffer.byteOffset, potentialBuffer.byteLength);
2740
2153
  }
2741
- if (utils.isAnyArrayBuffer(potentialBuffer)) {
2742
- return buffer.Buffer.from(potentialBuffer);
2154
+ if (isAnyArrayBuffer(potentialBuffer)) {
2155
+ return buffer_1.from(potentialBuffer);
2743
2156
  }
2744
2157
  throw new TypeError('Must use either Buffer or TypedArray');
2745
2158
  }
2746
- exports.ensureBuffer = ensureBuffer;
2747
- //# sourceMappingURL=ensure_buffer.js.map
2748
- });
2749
-
2750
- unwrapExports(ensure_buffer);
2751
- ensure_buffer.ensureBuffer;
2752
-
2753
- var uuid_utils = createCommonjsModule(function (module, exports) {
2754
- Object.defineProperty(exports, "__esModule", { value: true });
2755
- exports.bufferToUuidHexString = exports.uuidHexStringToBuffer = exports.uuidValidateString = void 0;
2756
2159
 
2757
2160
  // Validation regex for v4 uuid (validates with or without dashes)
2758
2161
  var VALIDATION_REGEX = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|[0-9a-f]{12}4[0-9a-f]{3}[89ab][0-9a-f]{15})$/i;
2759
2162
  var uuidValidateString = function (str) {
2760
2163
  return typeof str === 'string' && VALIDATION_REGEX.test(str);
2761
2164
  };
2762
- exports.uuidValidateString = uuidValidateString;
2763
2165
  var uuidHexStringToBuffer = function (hexString) {
2764
- if (!exports.uuidValidateString(hexString)) {
2166
+ if (!uuidValidateString(hexString)) {
2765
2167
  throw new TypeError('UUID string representations must be a 32 or 36 character hex string (dashes excluded/included). Format: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" or "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx".');
2766
2168
  }
2767
2169
  var sanitizedHexString = hexString.replace(/-/g, '');
2768
- return buffer.Buffer.from(sanitizedHexString, 'hex');
2170
+ return buffer_1.from(sanitizedHexString, 'hex');
2769
2171
  };
2770
- exports.uuidHexStringToBuffer = uuidHexStringToBuffer;
2771
2172
  var bufferToUuidHexString = function (buffer, includeDashes) {
2772
2173
  if (includeDashes === void 0) { includeDashes = true; }
2773
2174
  return includeDashes
@@ -2782,25 +2183,9 @@ var BSON = (function (exports) {
2782
2183
  buffer.toString('hex', 10, 16)
2783
2184
  : buffer.toString('hex');
2784
2185
  };
2785
- exports.bufferToUuidHexString = bufferToUuidHexString;
2786
- //# sourceMappingURL=uuid_utils.js.map
2787
- });
2788
-
2789
- unwrapExports(uuid_utils);
2790
- uuid_utils.bufferToUuidHexString;
2791
- uuid_utils.uuidHexStringToBuffer;
2792
- uuid_utils.uuidValidateString;
2793
-
2794
- var uuid = createCommonjsModule(function (module, exports) {
2795
- Object.defineProperty(exports, "__esModule", { value: true });
2796
- exports.UUID = void 0;
2797
-
2798
-
2799
-
2800
-
2801
2186
 
2802
2187
  var BYTE_LENGTH = 16;
2803
- var kId = Symbol('id');
2188
+ var kId$1 = Symbol('id');
2804
2189
  /**
2805
2190
  * A class representation of the BSON UUID type.
2806
2191
  * @public
@@ -2817,14 +2202,14 @@ var BSON = (function (exports) {
2817
2202
  this.id = UUID.generate();
2818
2203
  }
2819
2204
  else if (input instanceof UUID) {
2820
- this[kId] = buffer.Buffer.from(input.id);
2205
+ this[kId$1] = buffer_1.from(input.id);
2821
2206
  this.__id = input.__id;
2822
2207
  }
2823
2208
  else if (ArrayBuffer.isView(input) && input.byteLength === BYTE_LENGTH) {
2824
- this.id = ensure_buffer.ensureBuffer(input);
2209
+ this.id = ensureBuffer(input);
2825
2210
  }
2826
2211
  else if (typeof input === 'string') {
2827
- this.id = uuid_utils.uuidHexStringToBuffer(input);
2212
+ this.id = uuidHexStringToBuffer(input);
2828
2213
  }
2829
2214
  else {
2830
2215
  throw new TypeError('Argument passed in UUID constructor must be a UUID, a 16 byte Buffer or a 32/36 character hex string (dashes excluded/included, format: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx).');
@@ -2836,12 +2221,12 @@ var BSON = (function (exports) {
2836
2221
  * @readonly
2837
2222
  */
2838
2223
  get: function () {
2839
- return this[kId];
2224
+ return this[kId$1];
2840
2225
  },
2841
2226
  set: function (value) {
2842
- this[kId] = value;
2227
+ this[kId$1] = value;
2843
2228
  if (UUID.cacheHexString) {
2844
- this.__id = uuid_utils.bufferToUuidHexString(value);
2229
+ this.__id = bufferToUuidHexString(value);
2845
2230
  }
2846
2231
  },
2847
2232
  enumerable: false,
@@ -2859,7 +2244,7 @@ var BSON = (function (exports) {
2859
2244
  if (UUID.cacheHexString && this.__id) {
2860
2245
  return this.__id;
2861
2246
  }
2862
- var uuidHexString = uuid_utils.bufferToUuidHexString(this.id, includeDashes);
2247
+ var uuidHexString = bufferToUuidHexString(this.id, includeDashes);
2863
2248
  if (UUID.cacheHexString) {
2864
2249
  this.__id = uuidHexString;
2865
2250
  }
@@ -2867,14 +2252,13 @@ var BSON = (function (exports) {
2867
2252
  };
2868
2253
  /**
2869
2254
  * Converts the id into a 36 character (dashes included) hex string, unless a encoding is specified.
2870
- * @internal
2871
2255
  */
2872
2256
  UUID.prototype.toString = function (encoding) {
2873
2257
  return encoding ? this.id.toString(encoding) : this.toHexString();
2874
2258
  };
2875
2259
  /**
2876
- * Converts the id into its JSON string representation. A 36 character (dashes included) hex string in the format: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
2877
- * @internal
2260
+ * Converts the id into its JSON string representation.
2261
+ * A 36 character (dashes included) hex string in the format: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
2878
2262
  */
2879
2263
  UUID.prototype.toJSON = function () {
2880
2264
  return this.toHexString();
@@ -2902,18 +2286,18 @@ var BSON = (function (exports) {
2902
2286
  * Creates a Binary instance from the current UUID.
2903
2287
  */
2904
2288
  UUID.prototype.toBinary = function () {
2905
- return new binary.Binary(this.id, binary.Binary.SUBTYPE_UUID);
2289
+ return new Binary(this.id, Binary.SUBTYPE_UUID);
2906
2290
  };
2907
2291
  /**
2908
2292
  * Generates a populated buffer containing a v4 uuid
2909
2293
  */
2910
2294
  UUID.generate = function () {
2911
- var bytes = utils.randomBytes(BYTE_LENGTH);
2295
+ var bytes = randomBytes(BYTE_LENGTH);
2912
2296
  // Per 4.4, set bits for version and `clock_seq_hi_and_reserved`
2913
2297
  // Kindly borrowed from https://github.com/uuidjs/uuid/blob/master/src/v4.js
2914
2298
  bytes[6] = (bytes[6] & 0x0f) | 0x40;
2915
2299
  bytes[8] = (bytes[8] & 0x3f) | 0x80;
2916
- return buffer.Buffer.from(bytes);
2300
+ return buffer_1.from(bytes);
2917
2301
  };
2918
2302
  /**
2919
2303
  * Checks if a value is a valid bson UUID
@@ -2927,9 +2311,9 @@ var BSON = (function (exports) {
2927
2311
  return true;
2928
2312
  }
2929
2313
  if (typeof input === 'string') {
2930
- return uuid_utils.uuidValidateString(input);
2314
+ return uuidValidateString(input);
2931
2315
  }
2932
- if (utils.isUint8Array(input)) {
2316
+ if (isUint8Array(input)) {
2933
2317
  // check for length & uuid version (https://tools.ietf.org/html/rfc4122#section-4.1.3)
2934
2318
  if (input.length !== BYTE_LENGTH) {
2935
2319
  return false;
@@ -2937,7 +2321,7 @@ var BSON = (function (exports) {
2937
2321
  try {
2938
2322
  // get this byte as hex: xxxxxxxx-xxxx-XXxx-xxxx-xxxxxxxxxxxx
2939
2323
  // check first part as uuid version: xxxxxxxx-xxxx-Xxxx-xxxx-xxxxxxxxxxxx
2940
- return parseInt(input[6].toString(16)[0], 10) === binary.Binary.SUBTYPE_UUID;
2324
+ return parseInt(input[6].toString(16)[0], 10) === Binary.SUBTYPE_UUID;
2941
2325
  }
2942
2326
  catch (_a) {
2943
2327
  return false;
@@ -2950,7 +2334,7 @@ var BSON = (function (exports) {
2950
2334
  * @param hexString - 32 or 36 character hex string (dashes excluded/included).
2951
2335
  */
2952
2336
  UUID.createFromHexString = function (hexString) {
2953
- var buffer = uuid_utils.uuidHexStringToBuffer(hexString);
2337
+ var buffer = uuidHexStringToBuffer(hexString);
2954
2338
  return new UUID(buffer);
2955
2339
  };
2956
2340
  /**
@@ -2967,20 +2351,7 @@ var BSON = (function (exports) {
2967
2351
  };
2968
2352
  return UUID;
2969
2353
  }());
2970
- exports.UUID = UUID;
2971
2354
  Object.defineProperty(UUID.prototype, '_bsontype', { value: 'UUID' });
2972
- //# sourceMappingURL=uuid.js.map
2973
- });
2974
-
2975
- unwrapExports(uuid);
2976
- uuid.UUID;
2977
-
2978
- var binary = createCommonjsModule(function (module, exports) {
2979
- Object.defineProperty(exports, "__esModule", { value: true });
2980
- exports.Binary = void 0;
2981
-
2982
-
2983
-
2984
2355
 
2985
2356
  /**
2986
2357
  * A class representation of the BSON Binary type.
@@ -2991,34 +2362,34 @@ var BSON = (function (exports) {
2991
2362
  * @param buffer - a buffer object containing the binary data.
2992
2363
  * @param subType - the option binary type.
2993
2364
  */
2994
- function Binary(buffer$1, subType) {
2365
+ function Binary(buffer, subType) {
2995
2366
  if (!(this instanceof Binary))
2996
- return new Binary(buffer$1, subType);
2997
- if (!(buffer$1 == null) &&
2998
- !(typeof buffer$1 === 'string') &&
2999
- !ArrayBuffer.isView(buffer$1) &&
3000
- !(buffer$1 instanceof ArrayBuffer) &&
3001
- !Array.isArray(buffer$1)) {
2367
+ return new Binary(buffer, subType);
2368
+ if (!(buffer == null) &&
2369
+ !(typeof buffer === 'string') &&
2370
+ !ArrayBuffer.isView(buffer) &&
2371
+ !(buffer instanceof ArrayBuffer) &&
2372
+ !Array.isArray(buffer)) {
3002
2373
  throw new TypeError('Binary can only be constructed from string, Buffer, TypedArray, or Array<number>');
3003
2374
  }
3004
2375
  this.sub_type = subType !== null && subType !== void 0 ? subType : Binary.BSON_BINARY_SUBTYPE_DEFAULT;
3005
- if (buffer$1 == null) {
2376
+ if (buffer == null) {
3006
2377
  // create an empty binary buffer
3007
- this.buffer = buffer.Buffer.alloc(Binary.BUFFER_SIZE);
2378
+ this.buffer = buffer_1.alloc(Binary.BUFFER_SIZE);
3008
2379
  this.position = 0;
3009
2380
  }
3010
2381
  else {
3011
- if (typeof buffer$1 === 'string') {
2382
+ if (typeof buffer === 'string') {
3012
2383
  // string
3013
- this.buffer = buffer.Buffer.from(buffer$1, 'binary');
2384
+ this.buffer = buffer_1.from(buffer, 'binary');
3014
2385
  }
3015
- else if (Array.isArray(buffer$1)) {
2386
+ else if (Array.isArray(buffer)) {
3016
2387
  // number[]
3017
- this.buffer = buffer.Buffer.from(buffer$1);
2388
+ this.buffer = buffer_1.from(buffer);
3018
2389
  }
3019
2390
  else {
3020
2391
  // Buffer | TypedArray | ArrayBuffer
3021
- this.buffer = ensure_buffer.ensureBuffer(buffer$1);
2392
+ this.buffer = ensureBuffer(buffer);
3022
2393
  }
3023
2394
  this.position = this.buffer.byteLength;
3024
2395
  }
@@ -3053,10 +2424,10 @@ var BSON = (function (exports) {
3053
2424
  this.buffer[this.position++] = decodedByte;
3054
2425
  }
3055
2426
  else {
3056
- var buffer$1 = buffer.Buffer.alloc(Binary.BUFFER_SIZE + this.buffer.length);
2427
+ var buffer = buffer_1.alloc(Binary.BUFFER_SIZE + this.buffer.length);
3057
2428
  // Combine the two buffers together
3058
- this.buffer.copy(buffer$1, 0, 0, this.buffer.length);
3059
- this.buffer = buffer$1;
2429
+ this.buffer.copy(buffer, 0, 0, this.buffer.length);
2430
+ this.buffer = buffer;
3060
2431
  this.buffer[this.position++] = decodedByte;
3061
2432
  }
3062
2433
  };
@@ -3070,13 +2441,13 @@ var BSON = (function (exports) {
3070
2441
  offset = typeof offset === 'number' ? offset : this.position;
3071
2442
  // If the buffer is to small let's extend the buffer
3072
2443
  if (this.buffer.length < offset + sequence.length) {
3073
- var buffer$1 = buffer.Buffer.alloc(this.buffer.length + sequence.length);
3074
- this.buffer.copy(buffer$1, 0, 0, this.buffer.length);
2444
+ var buffer = buffer_1.alloc(this.buffer.length + sequence.length);
2445
+ this.buffer.copy(buffer, 0, 0, this.buffer.length);
3075
2446
  // Assign the new buffer
3076
- this.buffer = buffer$1;
2447
+ this.buffer = buffer;
3077
2448
  }
3078
2449
  if (ArrayBuffer.isView(sequence)) {
3079
- this.buffer.set(ensure_buffer.ensureBuffer(sequence), offset);
2450
+ this.buffer.set(ensureBuffer(sequence), offset);
3080
2451
  this.position =
3081
2452
  offset + sequence.byteLength > this.position ? offset + sequence.length : this.position;
3082
2453
  }
@@ -3119,11 +2490,9 @@ var BSON = (function (exports) {
3119
2490
  Binary.prototype.length = function () {
3120
2491
  return this.position;
3121
2492
  };
3122
- /** @internal */
3123
2493
  Binary.prototype.toJSON = function () {
3124
2494
  return this.buffer.toString('base64');
3125
2495
  };
3126
- /** @internal */
3127
2496
  Binary.prototype.toString = function (format) {
3128
2497
  return this.buffer.toString(format);
3129
2498
  };
@@ -3145,10 +2514,9 @@ var BSON = (function (exports) {
3145
2514
  }
3146
2515
  };
3147
2516
  };
3148
- /** @internal */
3149
2517
  Binary.prototype.toUUID = function () {
3150
2518
  if (this.sub_type === Binary.SUBTYPE_UUID) {
3151
- return new uuid.UUID(this.buffer.slice(0, this.position));
2519
+ return new UUID(this.buffer.slice(0, this.position));
3152
2520
  }
3153
2521
  throw new Error("Binary sub_type \"" + this.sub_type + "\" is not supported for converting to UUID. Only \"" + Binary.SUBTYPE_UUID + "\" is currently supported.");
3154
2522
  };
@@ -3160,18 +2528,18 @@ var BSON = (function (exports) {
3160
2528
  if ('$binary' in doc) {
3161
2529
  if (options.legacy && typeof doc.$binary === 'string' && '$type' in doc) {
3162
2530
  type = doc.$type ? parseInt(doc.$type, 16) : 0;
3163
- data = buffer.Buffer.from(doc.$binary, 'base64');
2531
+ data = buffer_1.from(doc.$binary, 'base64');
3164
2532
  }
3165
2533
  else {
3166
2534
  if (typeof doc.$binary !== 'string') {
3167
2535
  type = doc.$binary.subType ? parseInt(doc.$binary.subType, 16) : 0;
3168
- data = buffer.Buffer.from(doc.$binary.base64, 'base64');
2536
+ data = buffer_1.from(doc.$binary.base64, 'base64');
3169
2537
  }
3170
2538
  }
3171
2539
  }
3172
2540
  else if ('$uuid' in doc) {
3173
2541
  type = 4;
3174
- data = uuid_utils.uuidHexStringToBuffer(doc.$uuid);
2542
+ data = uuidHexStringToBuffer(doc.$uuid);
3175
2543
  }
3176
2544
  if (!data) {
3177
2545
  throw new TypeError("Unexpected Binary Extended JSON format " + JSON.stringify(doc));
@@ -3209,17 +2577,8 @@ var BSON = (function (exports) {
3209
2577
  Binary.SUBTYPE_USER_DEFINED = 128;
3210
2578
  return Binary;
3211
2579
  }());
3212
- exports.Binary = Binary;
3213
2580
  Object.defineProperty(Binary.prototype, '_bsontype', { value: 'Binary' });
3214
- //# sourceMappingURL=binary.js.map
3215
- });
3216
2581
 
3217
- unwrapExports(binary);
3218
- binary.Binary;
3219
-
3220
- var code = createCommonjsModule(function (module, exports) {
3221
- Object.defineProperty(exports, "__esModule", { value: true });
3222
- exports.Code = void 0;
3223
2582
  /**
3224
2583
  * A class representation of the BSON Code type.
3225
2584
  * @public
@@ -3235,7 +2594,6 @@ var BSON = (function (exports) {
3235
2594
  this.code = code;
3236
2595
  this.scope = scope;
3237
2596
  }
3238
- /** @internal */
3239
2597
  Code.prototype.toJSON = function () {
3240
2598
  return { code: this.code, scope: this.scope };
3241
2599
  };
@@ -3260,23 +2618,15 @@ var BSON = (function (exports) {
3260
2618
  };
3261
2619
  return Code;
3262
2620
  }());
3263
- exports.Code = Code;
3264
2621
  Object.defineProperty(Code.prototype, '_bsontype', { value: 'Code' });
3265
- //# sourceMappingURL=code.js.map
3266
- });
3267
-
3268
- unwrapExports(code);
3269
- code.Code;
3270
-
3271
- var db_ref = createCommonjsModule(function (module, exports) {
3272
- Object.defineProperty(exports, "__esModule", { value: true });
3273
- exports.DBRef = exports.isDBRefLike = void 0;
3274
2622
 
3275
2623
  /** @internal */
3276
2624
  function isDBRefLike(value) {
3277
- return utils.isObjectLike(value) && value['$id'] != null && value['$ref'] != null;
2625
+ return (isObjectLike(value) &&
2626
+ value.$id != null &&
2627
+ typeof value.$ref === 'string' &&
2628
+ (value.$db == null || typeof value.$db === 'string'));
3278
2629
  }
3279
- exports.isDBRefLike = isDBRefLike;
3280
2630
  /**
3281
2631
  * A class representation of the BSON DBRef type.
3282
2632
  * @public
@@ -3315,7 +2665,6 @@ var BSON = (function (exports) {
3315
2665
  enumerable: false,
3316
2666
  configurable: true
3317
2667
  });
3318
- /** @internal */
3319
2668
  DBRef.prototype.toJSON = function () {
3320
2669
  var o = Object.assign({
3321
2670
  $ref: this.collection,
@@ -3359,18 +2708,7 @@ var BSON = (function (exports) {
3359
2708
  };
3360
2709
  return DBRef;
3361
2710
  }());
3362
- exports.DBRef = DBRef;
3363
2711
  Object.defineProperty(DBRef.prototype, '_bsontype', { value: 'DBRef' });
3364
- //# sourceMappingURL=db_ref.js.map
3365
- });
3366
-
3367
- unwrapExports(db_ref);
3368
- db_ref.DBRef;
3369
- db_ref.isDBRefLike;
3370
-
3371
- var long_1 = createCommonjsModule(function (module, exports) {
3372
- Object.defineProperty(exports, "__esModule", { value: true });
3373
- exports.Long = void 0;
3374
2712
 
3375
2713
  /**
3376
2714
  * wasm optimizations, to do native i64 multiplication and divide
@@ -3604,7 +2942,7 @@ var BSON = (function (exports) {
3604
2942
  */
3605
2943
  // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types
3606
2944
  Long.isLong = function (value) {
3607
- return utils.isObjectLike(value) && value['__isLong__'] === true;
2945
+ return isObjectLike(value) && value['__isLong__'] === true;
3608
2946
  };
3609
2947
  /**
3610
2948
  * Converts the specified value to a Long.
@@ -4263,19 +3601,8 @@ var BSON = (function (exports) {
4263
3601
  Long.MIN_VALUE = Long.fromBits(0, 0x80000000 | 0, false);
4264
3602
  return Long;
4265
3603
  }());
4266
- exports.Long = Long;
4267
3604
  Object.defineProperty(Long.prototype, '__isLong__', { value: true });
4268
3605
  Object.defineProperty(Long.prototype, '_bsontype', { value: 'Long' });
4269
- //# sourceMappingURL=long.js.map
4270
- });
4271
-
4272
- unwrapExports(long_1);
4273
- long_1.Long;
4274
-
4275
- var decimal128 = createCommonjsModule(function (module, exports) {
4276
- Object.defineProperty(exports, "__esModule", { value: true });
4277
- exports.Decimal128 = void 0;
4278
-
4279
3606
 
4280
3607
  var PARSE_STRING_REGEXP = /^(\+|-)?(\d+|(\d*\.\d*))?(E|e)?([-+])?(\d+)?$/;
4281
3608
  var PARSE_INF_REGEXP = /^(\+|-)?(Infinity|inf)$/i;
@@ -4286,59 +3613,14 @@ var BSON = (function (exports) {
4286
3613
  var MAX_DIGITS = 34;
4287
3614
  // Nan value bits as 32 bit values (due to lack of longs)
4288
3615
  var NAN_BUFFER = [
4289
- 0x7c,
4290
- 0x00,
4291
- 0x00,
4292
- 0x00,
4293
- 0x00,
4294
- 0x00,
4295
- 0x00,
4296
- 0x00,
4297
- 0x00,
4298
- 0x00,
4299
- 0x00,
4300
- 0x00,
4301
- 0x00,
4302
- 0x00,
4303
- 0x00,
4304
- 0x00
3616
+ 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
4305
3617
  ].reverse();
4306
3618
  // Infinity value bits 32 bit values (due to lack of longs)
4307
3619
  var INF_NEGATIVE_BUFFER = [
4308
- 0xf8,
4309
- 0x00,
4310
- 0x00,
4311
- 0x00,
4312
- 0x00,
4313
- 0x00,
4314
- 0x00,
4315
- 0x00,
4316
- 0x00,
4317
- 0x00,
4318
- 0x00,
4319
- 0x00,
4320
- 0x00,
4321
- 0x00,
4322
- 0x00,
4323
- 0x00
3620
+ 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
4324
3621
  ].reverse();
4325
3622
  var INF_POSITIVE_BUFFER = [
4326
- 0x78,
4327
- 0x00,
4328
- 0x00,
4329
- 0x00,
4330
- 0x00,
4331
- 0x00,
4332
- 0x00,
4333
- 0x00,
4334
- 0x00,
4335
- 0x00,
4336
- 0x00,
4337
- 0x00,
4338
- 0x00,
4339
- 0x00,
4340
- 0x00,
4341
- 0x00
3623
+ 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
4342
3624
  ].reverse();
4343
3625
  var EXPONENT_REGEX = /^([-+])?(\d+)?$/;
4344
3626
  // Extract least significant 5 bits
@@ -4355,8 +3637,8 @@ var BSON = (function (exports) {
4355
3637
  }
4356
3638
  // Divide two uint128 values
4357
3639
  function divideu128(value) {
4358
- var DIVISOR = long_1.Long.fromNumber(1000 * 1000 * 1000);
4359
- var _rem = long_1.Long.fromNumber(0);
3640
+ var DIVISOR = Long.fromNumber(1000 * 1000 * 1000);
3641
+ var _rem = Long.fromNumber(0);
4360
3642
  if (!value.parts[0] && !value.parts[1] && !value.parts[2] && !value.parts[3]) {
4361
3643
  return { quotient: value, rem: _rem };
4362
3644
  }
@@ -4364,7 +3646,7 @@ var BSON = (function (exports) {
4364
3646
  // Adjust remainder to match value of next dividend
4365
3647
  _rem = _rem.shiftLeft(32);
4366
3648
  // Add the divided to _rem
4367
- _rem = _rem.add(new long_1.Long(value.parts[i], 0));
3649
+ _rem = _rem.add(new Long(value.parts[i], 0));
4368
3650
  value.parts[i] = _rem.div(DIVISOR).low;
4369
3651
  _rem = _rem.modulo(DIVISOR);
4370
3652
  }
@@ -4373,22 +3655,22 @@ var BSON = (function (exports) {
4373
3655
  // Multiply two Long values and return the 128 bit value
4374
3656
  function multiply64x2(left, right) {
4375
3657
  if (!left && !right) {
4376
- return { high: long_1.Long.fromNumber(0), low: long_1.Long.fromNumber(0) };
3658
+ return { high: Long.fromNumber(0), low: Long.fromNumber(0) };
4377
3659
  }
4378
3660
  var leftHigh = left.shiftRightUnsigned(32);
4379
- var leftLow = new long_1.Long(left.getLowBits(), 0);
3661
+ var leftLow = new Long(left.getLowBits(), 0);
4380
3662
  var rightHigh = right.shiftRightUnsigned(32);
4381
- var rightLow = new long_1.Long(right.getLowBits(), 0);
3663
+ var rightLow = new Long(right.getLowBits(), 0);
4382
3664
  var productHigh = leftHigh.multiply(rightHigh);
4383
3665
  var productMid = leftHigh.multiply(rightLow);
4384
3666
  var productMid2 = leftLow.multiply(rightHigh);
4385
3667
  var productLow = leftLow.multiply(rightLow);
4386
3668
  productHigh = productHigh.add(productMid.shiftRightUnsigned(32));
4387
- productMid = new long_1.Long(productMid.getLowBits(), 0)
3669
+ productMid = new Long(productMid.getLowBits(), 0)
4388
3670
  .add(productMid2)
4389
3671
  .add(productLow.shiftRightUnsigned(32));
4390
3672
  productHigh = productHigh.add(productMid.shiftRightUnsigned(32));
4391
- productLow = productMid.shiftLeft(32).add(new long_1.Long(productLow.getLowBits(), 0));
3673
+ productLow = productMid.shiftLeft(32).add(new Long(productLow.getLowBits(), 0));
4392
3674
  // Return the 128 bit result
4393
3675
  return { high: productHigh, low: productLow };
4394
3676
  }
@@ -4465,9 +3747,9 @@ var BSON = (function (exports) {
4465
3747
  // loop index over array
4466
3748
  var i = 0;
4467
3749
  // The high 17 digits of the significand
4468
- var significandHigh = new long_1.Long(0, 0);
3750
+ var significandHigh = new Long(0, 0);
4469
3751
  // The low 17 digits of the significand
4470
- var significandLow = new long_1.Long(0, 0);
3752
+ var significandLow = new Long(0, 0);
4471
3753
  // The biased exponent
4472
3754
  var biasedExponent = 0;
4473
3755
  // Read index
@@ -4512,10 +3794,10 @@ var BSON = (function (exports) {
4512
3794
  // Check if user passed Infinity or NaN
4513
3795
  if (!isDigit(representation[index]) && representation[index] !== '.') {
4514
3796
  if (representation[index] === 'i' || representation[index] === 'I') {
4515
- return new Decimal128(buffer.Buffer.from(isNegative ? INF_NEGATIVE_BUFFER : INF_POSITIVE_BUFFER));
3797
+ return new Decimal128(buffer_1.from(isNegative ? INF_NEGATIVE_BUFFER : INF_POSITIVE_BUFFER));
4516
3798
  }
4517
3799
  else if (representation[index] === 'N') {
4518
- return new Decimal128(buffer.Buffer.from(NAN_BUFFER));
3800
+ return new Decimal128(buffer_1.from(NAN_BUFFER));
4519
3801
  }
4520
3802
  }
4521
3803
  // Read all the digits
@@ -4553,7 +3835,7 @@ var BSON = (function (exports) {
4553
3835
  var match = representation.substr(++index).match(EXPONENT_REGEX);
4554
3836
  // No digits read
4555
3837
  if (!match || !match[2])
4556
- return new Decimal128(buffer.Buffer.from(NAN_BUFFER));
3838
+ return new Decimal128(buffer_1.from(NAN_BUFFER));
4557
3839
  // Get exponent
4558
3840
  exponent = parseInt(match[0], 10);
4559
3841
  // Adjust the index
@@ -4561,7 +3843,7 @@ var BSON = (function (exports) {
4561
3843
  }
4562
3844
  // Return not a number
4563
3845
  if (representation[index])
4564
- return new Decimal128(buffer.Buffer.from(NAN_BUFFER));
3846
+ return new Decimal128(buffer_1.from(NAN_BUFFER));
4565
3847
  // Done reading input
4566
3848
  // Find first non-zero digit in digits
4567
3849
  firstDigit = 0;
@@ -4577,7 +3859,7 @@ var BSON = (function (exports) {
4577
3859
  lastDigit = nDigitsStored - 1;
4578
3860
  significantDigits = nDigits;
4579
3861
  if (significantDigits !== 1) {
4580
- while (representation[firstNonZero + significantDigits - 1] === '0') {
3862
+ while (digits[firstNonZero + significantDigits - 1] === 0) {
4581
3863
  significantDigits = significantDigits - 1;
4582
3864
  }
4583
3865
  }
@@ -4677,7 +3959,7 @@ var BSON = (function (exports) {
4677
3959
  digits[dIdx] = 1;
4678
3960
  }
4679
3961
  else {
4680
- return new Decimal128(buffer.Buffer.from(isNegative ? INF_NEGATIVE_BUFFER : INF_POSITIVE_BUFFER));
3962
+ return new Decimal128(buffer_1.from(isNegative ? INF_NEGATIVE_BUFFER : INF_POSITIVE_BUFFER));
4681
3963
  }
4682
3964
  }
4683
3965
  }
@@ -4686,87 +3968,87 @@ var BSON = (function (exports) {
4686
3968
  }
4687
3969
  // Encode significand
4688
3970
  // The high 17 digits of the significand
4689
- significandHigh = long_1.Long.fromNumber(0);
3971
+ significandHigh = Long.fromNumber(0);
4690
3972
  // The low 17 digits of the significand
4691
- significandLow = long_1.Long.fromNumber(0);
3973
+ significandLow = Long.fromNumber(0);
4692
3974
  // read a zero
4693
3975
  if (significantDigits === 0) {
4694
- significandHigh = long_1.Long.fromNumber(0);
4695
- significandLow = long_1.Long.fromNumber(0);
3976
+ significandHigh = Long.fromNumber(0);
3977
+ significandLow = Long.fromNumber(0);
4696
3978
  }
4697
3979
  else if (lastDigit - firstDigit < 17) {
4698
3980
  var dIdx = firstDigit;
4699
- significandLow = long_1.Long.fromNumber(digits[dIdx++]);
4700
- significandHigh = new long_1.Long(0, 0);
3981
+ significandLow = Long.fromNumber(digits[dIdx++]);
3982
+ significandHigh = new Long(0, 0);
4701
3983
  for (; dIdx <= lastDigit; dIdx++) {
4702
- significandLow = significandLow.multiply(long_1.Long.fromNumber(10));
4703
- significandLow = significandLow.add(long_1.Long.fromNumber(digits[dIdx]));
3984
+ significandLow = significandLow.multiply(Long.fromNumber(10));
3985
+ significandLow = significandLow.add(Long.fromNumber(digits[dIdx]));
4704
3986
  }
4705
3987
  }
4706
3988
  else {
4707
3989
  var dIdx = firstDigit;
4708
- significandHigh = long_1.Long.fromNumber(digits[dIdx++]);
3990
+ significandHigh = Long.fromNumber(digits[dIdx++]);
4709
3991
  for (; dIdx <= lastDigit - 17; dIdx++) {
4710
- significandHigh = significandHigh.multiply(long_1.Long.fromNumber(10));
4711
- significandHigh = significandHigh.add(long_1.Long.fromNumber(digits[dIdx]));
3992
+ significandHigh = significandHigh.multiply(Long.fromNumber(10));
3993
+ significandHigh = significandHigh.add(Long.fromNumber(digits[dIdx]));
4712
3994
  }
4713
- significandLow = long_1.Long.fromNumber(digits[dIdx++]);
3995
+ significandLow = Long.fromNumber(digits[dIdx++]);
4714
3996
  for (; dIdx <= lastDigit; dIdx++) {
4715
- significandLow = significandLow.multiply(long_1.Long.fromNumber(10));
4716
- significandLow = significandLow.add(long_1.Long.fromNumber(digits[dIdx]));
3997
+ significandLow = significandLow.multiply(Long.fromNumber(10));
3998
+ significandLow = significandLow.add(Long.fromNumber(digits[dIdx]));
4717
3999
  }
4718
4000
  }
4719
- var significand = multiply64x2(significandHigh, long_1.Long.fromString('100000000000000000'));
4001
+ var significand = multiply64x2(significandHigh, Long.fromString('100000000000000000'));
4720
4002
  significand.low = significand.low.add(significandLow);
4721
4003
  if (lessThan(significand.low, significandLow)) {
4722
- significand.high = significand.high.add(long_1.Long.fromNumber(1));
4004
+ significand.high = significand.high.add(Long.fromNumber(1));
4723
4005
  }
4724
4006
  // Biased exponent
4725
4007
  biasedExponent = exponent + EXPONENT_BIAS;
4726
- var dec = { low: long_1.Long.fromNumber(0), high: long_1.Long.fromNumber(0) };
4008
+ var dec = { low: Long.fromNumber(0), high: Long.fromNumber(0) };
4727
4009
  // Encode combination, exponent, and significand.
4728
- if (significand.high.shiftRightUnsigned(49).and(long_1.Long.fromNumber(1)).equals(long_1.Long.fromNumber(1))) {
4010
+ if (significand.high.shiftRightUnsigned(49).and(Long.fromNumber(1)).equals(Long.fromNumber(1))) {
4729
4011
  // Encode '11' into bits 1 to 3
4730
- dec.high = dec.high.or(long_1.Long.fromNumber(0x3).shiftLeft(61));
4731
- dec.high = dec.high.or(long_1.Long.fromNumber(biasedExponent).and(long_1.Long.fromNumber(0x3fff).shiftLeft(47)));
4732
- dec.high = dec.high.or(significand.high.and(long_1.Long.fromNumber(0x7fffffffffff)));
4012
+ dec.high = dec.high.or(Long.fromNumber(0x3).shiftLeft(61));
4013
+ dec.high = dec.high.or(Long.fromNumber(biasedExponent).and(Long.fromNumber(0x3fff).shiftLeft(47)));
4014
+ dec.high = dec.high.or(significand.high.and(Long.fromNumber(0x7fffffffffff)));
4733
4015
  }
4734
4016
  else {
4735
- dec.high = dec.high.or(long_1.Long.fromNumber(biasedExponent & 0x3fff).shiftLeft(49));
4736
- dec.high = dec.high.or(significand.high.and(long_1.Long.fromNumber(0x1ffffffffffff)));
4017
+ dec.high = dec.high.or(Long.fromNumber(biasedExponent & 0x3fff).shiftLeft(49));
4018
+ dec.high = dec.high.or(significand.high.and(Long.fromNumber(0x1ffffffffffff)));
4737
4019
  }
4738
4020
  dec.low = significand.low;
4739
4021
  // Encode sign
4740
4022
  if (isNegative) {
4741
- dec.high = dec.high.or(long_1.Long.fromString('9223372036854775808'));
4023
+ dec.high = dec.high.or(Long.fromString('9223372036854775808'));
4742
4024
  }
4743
4025
  // Encode into a buffer
4744
- var buffer$1 = buffer.Buffer.alloc(16);
4026
+ var buffer = buffer_1.alloc(16);
4745
4027
  index = 0;
4746
4028
  // Encode the low 64 bits of the decimal
4747
4029
  // Encode low bits
4748
- buffer$1[index++] = dec.low.low & 0xff;
4749
- buffer$1[index++] = (dec.low.low >> 8) & 0xff;
4750
- buffer$1[index++] = (dec.low.low >> 16) & 0xff;
4751
- buffer$1[index++] = (dec.low.low >> 24) & 0xff;
4030
+ buffer[index++] = dec.low.low & 0xff;
4031
+ buffer[index++] = (dec.low.low >> 8) & 0xff;
4032
+ buffer[index++] = (dec.low.low >> 16) & 0xff;
4033
+ buffer[index++] = (dec.low.low >> 24) & 0xff;
4752
4034
  // Encode high bits
4753
- buffer$1[index++] = dec.low.high & 0xff;
4754
- buffer$1[index++] = (dec.low.high >> 8) & 0xff;
4755
- buffer$1[index++] = (dec.low.high >> 16) & 0xff;
4756
- buffer$1[index++] = (dec.low.high >> 24) & 0xff;
4035
+ buffer[index++] = dec.low.high & 0xff;
4036
+ buffer[index++] = (dec.low.high >> 8) & 0xff;
4037
+ buffer[index++] = (dec.low.high >> 16) & 0xff;
4038
+ buffer[index++] = (dec.low.high >> 24) & 0xff;
4757
4039
  // Encode the high 64 bits of the decimal
4758
4040
  // Encode low bits
4759
- buffer$1[index++] = dec.high.low & 0xff;
4760
- buffer$1[index++] = (dec.high.low >> 8) & 0xff;
4761
- buffer$1[index++] = (dec.high.low >> 16) & 0xff;
4762
- buffer$1[index++] = (dec.high.low >> 24) & 0xff;
4041
+ buffer[index++] = dec.high.low & 0xff;
4042
+ buffer[index++] = (dec.high.low >> 8) & 0xff;
4043
+ buffer[index++] = (dec.high.low >> 16) & 0xff;
4044
+ buffer[index++] = (dec.high.low >> 24) & 0xff;
4763
4045
  // Encode high bits
4764
- buffer$1[index++] = dec.high.high & 0xff;
4765
- buffer$1[index++] = (dec.high.high >> 8) & 0xff;
4766
- buffer$1[index++] = (dec.high.high >> 16) & 0xff;
4767
- buffer$1[index++] = (dec.high.high >> 24) & 0xff;
4046
+ buffer[index++] = dec.high.high & 0xff;
4047
+ buffer[index++] = (dec.high.high >> 8) & 0xff;
4048
+ buffer[index++] = (dec.high.high >> 16) & 0xff;
4049
+ buffer[index++] = (dec.high.high >> 24) & 0xff;
4768
4050
  // Return the new Decimal128
4769
- return new Decimal128(buffer$1);
4051
+ return new Decimal128(buffer);
4770
4052
  };
4771
4053
  /** Create a string representation of the raw Decimal128 value */
4772
4054
  Decimal128.prototype.toString = function () {
@@ -4810,10 +4092,10 @@ var BSON = (function (exports) {
4810
4092
  index = 0;
4811
4093
  // Create the state of the decimal
4812
4094
  var dec = {
4813
- low: new long_1.Long(low, midl),
4814
- high: new long_1.Long(midh, high)
4095
+ low: new Long(low, midl),
4096
+ high: new Long(midh, high)
4815
4097
  };
4816
- if (dec.high.lessThan(long_1.Long.ZERO)) {
4098
+ if (dec.high.lessThan(Long.ZERO)) {
4817
4099
  string.push('-');
4818
4100
  }
4819
4101
  // Decode combination field and exponent
@@ -4974,17 +4256,8 @@ var BSON = (function (exports) {
4974
4256
  };
4975
4257
  return Decimal128;
4976
4258
  }());
4977
- exports.Decimal128 = Decimal128;
4978
4259
  Object.defineProperty(Decimal128.prototype, '_bsontype', { value: 'Decimal128' });
4979
- //# sourceMappingURL=decimal128.js.map
4980
- });
4981
4260
 
4982
- unwrapExports(decimal128);
4983
- decimal128.Decimal128;
4984
-
4985
- var double_1 = createCommonjsModule(function (module, exports) {
4986
- Object.defineProperty(exports, "__esModule", { value: true });
4987
- exports.Double = void 0;
4988
4261
  /**
4989
4262
  * A class representation of the BSON Double type.
4990
4263
  * @public
@@ -5011,10 +4284,12 @@ var BSON = (function (exports) {
5011
4284
  Double.prototype.valueOf = function () {
5012
4285
  return this.value;
5013
4286
  };
5014
- /** @internal */
5015
4287
  Double.prototype.toJSON = function () {
5016
4288
  return this.value;
5017
4289
  };
4290
+ Double.prototype.toString = function (radix) {
4291
+ return this.value.toString(radix);
4292
+ };
5018
4293
  /** @internal */
5019
4294
  Double.prototype.toExtendedJSON = function (options) {
5020
4295
  if (options && (options.legacy || (options.relaxed && isFinite(this.value)))) {
@@ -5052,17 +4327,8 @@ var BSON = (function (exports) {
5052
4327
  };
5053
4328
  return Double;
5054
4329
  }());
5055
- exports.Double = Double;
5056
4330
  Object.defineProperty(Double.prototype, '_bsontype', { value: 'Double' });
5057
- //# sourceMappingURL=double.js.map
5058
- });
5059
-
5060
- unwrapExports(double_1);
5061
- double_1.Double;
5062
4331
 
5063
- var int_32 = createCommonjsModule(function (module, exports) {
5064
- Object.defineProperty(exports, "__esModule", { value: true });
5065
- exports.Int32 = void 0;
5066
4332
  /**
5067
4333
  * A class representation of a BSON Int32 type.
5068
4334
  * @public
@@ -5089,7 +4355,9 @@ var BSON = (function (exports) {
5089
4355
  Int32.prototype.valueOf = function () {
5090
4356
  return this.value;
5091
4357
  };
5092
- /** @internal */
4358
+ Int32.prototype.toString = function (radix) {
4359
+ return this.value.toString(radix);
4360
+ };
5093
4361
  Int32.prototype.toJSON = function () {
5094
4362
  return this.value;
5095
4363
  };
@@ -5112,17 +4380,8 @@ var BSON = (function (exports) {
5112
4380
  };
5113
4381
  return Int32;
5114
4382
  }());
5115
- exports.Int32 = Int32;
5116
4383
  Object.defineProperty(Int32.prototype, '_bsontype', { value: 'Int32' });
5117
- //# sourceMappingURL=int_32.js.map
5118
- });
5119
-
5120
- unwrapExports(int_32);
5121
- int_32.Int32;
5122
4384
 
5123
- var max_key = createCommonjsModule(function (module, exports) {
5124
- Object.defineProperty(exports, "__esModule", { value: true });
5125
- exports.MaxKey = void 0;
5126
4385
  /**
5127
4386
  * A class representation of the BSON MaxKey type.
5128
4387
  * @public
@@ -5149,17 +4408,8 @@ var BSON = (function (exports) {
5149
4408
  };
5150
4409
  return MaxKey;
5151
4410
  }());
5152
- exports.MaxKey = MaxKey;
5153
4411
  Object.defineProperty(MaxKey.prototype, '_bsontype', { value: 'MaxKey' });
5154
- //# sourceMappingURL=max_key.js.map
5155
- });
5156
-
5157
- unwrapExports(max_key);
5158
- max_key.MaxKey;
5159
4412
 
5160
- var min_key = createCommonjsModule(function (module, exports) {
5161
- Object.defineProperty(exports, "__esModule", { value: true });
5162
- exports.MinKey = void 0;
5163
4413
  /**
5164
4414
  * A class representation of the BSON MinKey type.
5165
4415
  * @public
@@ -5186,19 +4436,7 @@ var BSON = (function (exports) {
5186
4436
  };
5187
4437
  return MinKey;
5188
4438
  }());
5189
- exports.MinKey = MinKey;
5190
4439
  Object.defineProperty(MinKey.prototype, '_bsontype', { value: 'MinKey' });
5191
- //# sourceMappingURL=min_key.js.map
5192
- });
5193
-
5194
- unwrapExports(min_key);
5195
- min_key.MinKey;
5196
-
5197
- var objectid = createCommonjsModule(function (module, exports) {
5198
- Object.defineProperty(exports, "__esModule", { value: true });
5199
- exports.ObjectId = void 0;
5200
-
5201
-
5202
4440
 
5203
4441
  // Regular expression that checks for hex value
5204
4442
  var checkForHexRegExp = new RegExp('^[0-9a-fA-F]{24}$');
@@ -5225,10 +4463,10 @@ var BSON = (function (exports) {
5225
4463
  }
5226
4464
  if (typeof id === 'object' && id && 'id' in id) {
5227
4465
  if ('toHexString' in id && typeof id.toHexString === 'function') {
5228
- this[kId] = buffer.Buffer.from(id.toHexString(), 'hex');
4466
+ this[kId] = buffer_1.from(id.toHexString(), 'hex');
5229
4467
  }
5230
4468
  else {
5231
- this[kId] = typeof id.id === 'string' ? buffer.Buffer.from(id.id) : id.id;
4469
+ this[kId] = typeof id.id === 'string' ? buffer_1.from(id.id) : id.id;
5232
4470
  }
5233
4471
  }
5234
4472
  // The most common use case (blank id, new objectId instance)
@@ -5241,17 +4479,17 @@ var BSON = (function (exports) {
5241
4479
  }
5242
4480
  }
5243
4481
  if (ArrayBuffer.isView(id) && id.byteLength === 12) {
5244
- this[kId] = ensure_buffer.ensureBuffer(id);
4482
+ this[kId] = ensureBuffer(id);
5245
4483
  }
5246
4484
  if (typeof id === 'string') {
5247
4485
  if (id.length === 12) {
5248
- var bytes = buffer.Buffer.from(id);
4486
+ var bytes = buffer_1.from(id);
5249
4487
  if (bytes.byteLength === 12) {
5250
4488
  this[kId] = bytes;
5251
4489
  }
5252
4490
  }
5253
4491
  else if (id.length === 24 && checkForHexRegExp.test(id)) {
5254
- this[kId] = buffer.Buffer.from(id, 'hex');
4492
+ this[kId] = buffer_1.from(id, 'hex');
5255
4493
  }
5256
4494
  else {
5257
4495
  throw new TypeError('Argument passed in must be a Buffer or string of 12 bytes or a string of 24 hex characters');
@@ -5323,30 +4561,29 @@ var BSON = (function (exports) {
5323
4561
  time = ~~(Date.now() / 1000);
5324
4562
  }
5325
4563
  var inc = ObjectId.getInc();
5326
- var buffer$1 = buffer.Buffer.alloc(12);
4564
+ var buffer = buffer_1.alloc(12);
5327
4565
  // 4-byte timestamp
5328
- buffer$1.writeUInt32BE(time, 0);
4566
+ buffer.writeUInt32BE(time, 0);
5329
4567
  // set PROCESS_UNIQUE if yet not initialized
5330
4568
  if (PROCESS_UNIQUE === null) {
5331
- PROCESS_UNIQUE = utils.randomBytes(5);
4569
+ PROCESS_UNIQUE = randomBytes(5);
5332
4570
  }
5333
4571
  // 5-byte process unique
5334
- buffer$1[4] = PROCESS_UNIQUE[0];
5335
- buffer$1[5] = PROCESS_UNIQUE[1];
5336
- buffer$1[6] = PROCESS_UNIQUE[2];
5337
- buffer$1[7] = PROCESS_UNIQUE[3];
5338
- buffer$1[8] = PROCESS_UNIQUE[4];
4572
+ buffer[4] = PROCESS_UNIQUE[0];
4573
+ buffer[5] = PROCESS_UNIQUE[1];
4574
+ buffer[6] = PROCESS_UNIQUE[2];
4575
+ buffer[7] = PROCESS_UNIQUE[3];
4576
+ buffer[8] = PROCESS_UNIQUE[4];
5339
4577
  // 3-byte counter
5340
- buffer$1[11] = inc & 0xff;
5341
- buffer$1[10] = (inc >> 8) & 0xff;
5342
- buffer$1[9] = (inc >> 16) & 0xff;
5343
- return buffer$1;
4578
+ buffer[11] = inc & 0xff;
4579
+ buffer[10] = (inc >> 8) & 0xff;
4580
+ buffer[9] = (inc >> 16) & 0xff;
4581
+ return buffer;
5344
4582
  };
5345
4583
  /**
5346
4584
  * Converts the id into a 24 character hex string for printing
5347
4585
  *
5348
4586
  * @param format - The Buffer toString format parameter.
5349
- * @internal
5350
4587
  */
5351
4588
  ObjectId.prototype.toString = function (format) {
5352
4589
  // Is the id a buffer then use the buffer toString method to return the format
@@ -5354,10 +4591,7 @@ var BSON = (function (exports) {
5354
4591
  return this.id.toString(format);
5355
4592
  return this.toHexString();
5356
4593
  };
5357
- /**
5358
- * Converts to its JSON the 24 character hex string representation.
5359
- * @internal
5360
- */
4594
+ /** Converts to its JSON the 24 character hex string representation. */
5361
4595
  ObjectId.prototype.toJSON = function () {
5362
4596
  return this.toHexString();
5363
4597
  };
@@ -5376,14 +4610,14 @@ var BSON = (function (exports) {
5376
4610
  if (typeof otherId === 'string' &&
5377
4611
  ObjectId.isValid(otherId) &&
5378
4612
  otherId.length === 12 &&
5379
- utils.isUint8Array(this.id)) {
5380
- return otherId === buffer.Buffer.prototype.toString.call(this.id, 'latin1');
4613
+ isUint8Array(this.id)) {
4614
+ return otherId === buffer_1.prototype.toString.call(this.id, 'latin1');
5381
4615
  }
5382
4616
  if (typeof otherId === 'string' && ObjectId.isValid(otherId) && otherId.length === 24) {
5383
4617
  return otherId.toLowerCase() === this.toHexString();
5384
4618
  }
5385
4619
  if (typeof otherId === 'string' && ObjectId.isValid(otherId) && otherId.length === 12) {
5386
- return buffer.Buffer.from(otherId).equals(this.id);
4620
+ return buffer_1.from(otherId).equals(this.id);
5387
4621
  }
5388
4622
  if (typeof otherId === 'object' &&
5389
4623
  'toHexString' in otherId &&
@@ -5409,11 +4643,11 @@ var BSON = (function (exports) {
5409
4643
  * @param time - an integer number representing a number of seconds.
5410
4644
  */
5411
4645
  ObjectId.createFromTime = function (time) {
5412
- var buffer$1 = buffer.Buffer.from([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]);
4646
+ var buffer = buffer_1.from([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]);
5413
4647
  // Encode time into first 4 bytes
5414
- buffer$1.writeUInt32BE(time, 0);
4648
+ buffer.writeUInt32BE(time, 0);
5415
4649
  // Return the new objectId
5416
- return new ObjectId(buffer$1);
4650
+ return new ObjectId(buffer);
5417
4651
  };
5418
4652
  /**
5419
4653
  * Creates an ObjectId from a hex string representation of an ObjectId.
@@ -5425,7 +4659,7 @@ var BSON = (function (exports) {
5425
4659
  if (typeof hexString === 'undefined' || (hexString != null && hexString.length !== 24)) {
5426
4660
  throw new TypeError('Argument passed in must be a single String of 12 bytes or a string of 24 hex characters');
5427
4661
  }
5428
- return new ObjectId(buffer.Buffer.from(hexString, 'hex'));
4662
+ return new ObjectId(buffer_1.from(hexString, 'hex'));
5429
4663
  };
5430
4664
  /**
5431
4665
  * Checks if a value is a valid bson ObjectId
@@ -5444,7 +4678,7 @@ var BSON = (function (exports) {
5444
4678
  if (id instanceof ObjectId) {
5445
4679
  return true;
5446
4680
  }
5447
- if (utils.isUint8Array(id) && id.length === 12) {
4681
+ if (isUint8Array(id) && id.length === 12) {
5448
4682
  return true;
5449
4683
  }
5450
4684
  // Duck-Typing detection of ObjectId like objects
@@ -5482,30 +4716,21 @@ var BSON = (function (exports) {
5482
4716
  ObjectId.index = ~~(Math.random() * 0xffffff);
5483
4717
  return ObjectId;
5484
4718
  }());
5485
- exports.ObjectId = ObjectId;
5486
4719
  // Deprecated methods
5487
4720
  Object.defineProperty(ObjectId.prototype, 'generate', {
5488
- value: utils.deprecate(function (time) { return ObjectId.generate(time); }, 'Please use the static `ObjectId.generate(time)` instead')
4721
+ value: deprecate(function (time) { return ObjectId.generate(time); }, 'Please use the static `ObjectId.generate(time)` instead')
5489
4722
  });
5490
4723
  Object.defineProperty(ObjectId.prototype, 'getInc', {
5491
- value: utils.deprecate(function () { return ObjectId.getInc(); }, 'Please use the static `ObjectId.getInc()` instead')
4724
+ value: deprecate(function () { return ObjectId.getInc(); }, 'Please use the static `ObjectId.getInc()` instead')
5492
4725
  });
5493
4726
  Object.defineProperty(ObjectId.prototype, 'get_inc', {
5494
- value: utils.deprecate(function () { return ObjectId.getInc(); }, 'Please use the static `ObjectId.getInc()` instead')
4727
+ value: deprecate(function () { return ObjectId.getInc(); }, 'Please use the static `ObjectId.getInc()` instead')
5495
4728
  });
5496
4729
  Object.defineProperty(ObjectId, 'get_inc', {
5497
- value: utils.deprecate(function () { return ObjectId.getInc(); }, 'Please use the static `ObjectId.getInc()` instead')
4730
+ value: deprecate(function () { return ObjectId.getInc(); }, 'Please use the static `ObjectId.getInc()` instead')
5498
4731
  });
5499
4732
  Object.defineProperty(ObjectId.prototype, '_bsontype', { value: 'ObjectID' });
5500
- //# sourceMappingURL=objectid.js.map
5501
- });
5502
4733
 
5503
- unwrapExports(objectid);
5504
- objectid.ObjectId;
5505
-
5506
- var regexp = createCommonjsModule(function (module, exports) {
5507
- Object.defineProperty(exports, "__esModule", { value: true });
5508
- exports.BSONRegExp = void 0;
5509
4734
  function alphabetize(str) {
5510
4735
  return str.split('').sort().join('');
5511
4736
  }
@@ -5522,9 +4747,7 @@ var BSON = (function (exports) {
5522
4747
  if (!(this instanceof BSONRegExp))
5523
4748
  return new BSONRegExp(pattern, options);
5524
4749
  this.pattern = pattern;
5525
- this.options = options !== null && options !== void 0 ? options : '';
5526
- // Execute
5527
- alphabetize(this.options);
4750
+ this.options = alphabetize(options !== null && options !== void 0 ? options : '');
5528
4751
  // Validate options
5529
4752
  for (var i = 0; i < this.options.length; i++) {
5530
4753
  if (!(this.options[i] === 'i' ||
@@ -5568,17 +4791,8 @@ var BSON = (function (exports) {
5568
4791
  };
5569
4792
  return BSONRegExp;
5570
4793
  }());
5571
- exports.BSONRegExp = BSONRegExp;
5572
4794
  Object.defineProperty(BSONRegExp.prototype, '_bsontype', { value: 'BSONRegExp' });
5573
- //# sourceMappingURL=regexp.js.map
5574
- });
5575
4795
 
5576
- unwrapExports(regexp);
5577
- regexp.BSONRegExp;
5578
-
5579
- var symbol = createCommonjsModule(function (module, exports) {
5580
- Object.defineProperty(exports, "__esModule", { value: true });
5581
- exports.BSONSymbol = void 0;
5582
4796
  /**
5583
4797
  * A class representation of the BSON Symbol type.
5584
4798
  * @public
@@ -5596,7 +4810,6 @@ var BSON = (function (exports) {
5596
4810
  BSONSymbol.prototype.valueOf = function () {
5597
4811
  return this.value;
5598
4812
  };
5599
- /** @internal */
5600
4813
  BSONSymbol.prototype.toString = function () {
5601
4814
  return this.value;
5602
4815
  };
@@ -5604,7 +4817,6 @@ var BSON = (function (exports) {
5604
4817
  BSONSymbol.prototype.inspect = function () {
5605
4818
  return "new BSONSymbol(\"" + this.value + "\")";
5606
4819
  };
5607
- /** @internal */
5608
4820
  BSONSymbol.prototype.toJSON = function () {
5609
4821
  return this.value;
5610
4822
  };
@@ -5622,13 +4834,7 @@ var BSON = (function (exports) {
5622
4834
  };
5623
4835
  return BSONSymbol;
5624
4836
  }());
5625
- exports.BSONSymbol = BSONSymbol;
5626
4837
  Object.defineProperty(BSONSymbol.prototype, '_bsontype', { value: 'Symbol' });
5627
- //# sourceMappingURL=symbol.js.map
5628
- });
5629
-
5630
- unwrapExports(symbol);
5631
- symbol.BSONSymbol;
5632
4838
 
5633
4839
  /*! *****************************************************************************
5634
4840
  Copyright (c) Microsoft Corporation.
@@ -5670,435 +4876,23 @@ var BSON = (function (exports) {
5670
4876
  d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
5671
4877
  }
5672
4878
 
5673
- var _assign = function __assign() {
5674
- _assign = Object.assign || function __assign(t) {
5675
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5676
- s = arguments[i];
5677
-
5678
- for (var p in s) {
5679
- if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
5680
- }
5681
- }
5682
-
5683
- return t;
5684
- };
5685
-
5686
- return _assign.apply(this, arguments);
5687
- };
5688
- function __rest(s, e) {
5689
- var t = {};
5690
-
5691
- for (var p in s) {
5692
- if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
5693
- }
5694
-
5695
- if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
5696
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
5697
- }
5698
- return t;
5699
- }
5700
- function __decorate(decorators, target, key, desc) {
5701
- var c = arguments.length,
5702
- r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
5703
- d;
5704
- if ((typeof Reflect === "undefined" ? "undefined" : babelHelpers["typeof"](Reflect)) === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);else for (var i = decorators.length - 1; i >= 0; i--) {
5705
- if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5706
- }
5707
- return c > 3 && r && Object.defineProperty(target, key, r), r;
5708
- }
5709
- function __param(paramIndex, decorator) {
5710
- return function (target, key) {
5711
- decorator(target, key, paramIndex);
5712
- };
5713
- }
5714
- function __metadata(metadataKey, metadataValue) {
5715
- if ((typeof Reflect === "undefined" ? "undefined" : babelHelpers["typeof"](Reflect)) === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
5716
- }
5717
- function __awaiter(thisArg, _arguments, P, generator) {
5718
- function adopt(value) {
5719
- return value instanceof P ? value : new P(function (resolve) {
5720
- resolve(value);
5721
- });
5722
- }
5723
-
5724
- return new (P || (P = Promise))(function (resolve, reject) {
5725
- function fulfilled(value) {
5726
- try {
5727
- step(generator.next(value));
5728
- } catch (e) {
5729
- reject(e);
5730
- }
5731
- }
5732
-
5733
- function rejected(value) {
5734
- try {
5735
- step(generator["throw"](value));
5736
- } catch (e) {
5737
- reject(e);
5738
- }
5739
- }
5740
-
5741
- function step(result) {
5742
- result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
5743
- }
5744
-
5745
- step((generator = generator.apply(thisArg, _arguments || [])).next());
5746
- });
5747
- }
5748
- function __generator(thisArg, body) {
5749
- var _ = {
5750
- label: 0,
5751
- sent: function sent() {
5752
- if (t[0] & 1) throw t[1];
5753
- return t[1];
5754
- },
5755
- trys: [],
5756
- ops: []
5757
- },
5758
- f,
5759
- y,
5760
- t,
5761
- g;
5762
- return g = {
5763
- next: verb(0),
5764
- "throw": verb(1),
5765
- "return": verb(2)
5766
- }, typeof Symbol === "function" && (g[Symbol.iterator] = function () {
5767
- return this;
5768
- }), g;
5769
-
5770
- function verb(n) {
5771
- return function (v) {
5772
- return step([n, v]);
5773
- };
5774
- }
5775
-
5776
- function step(op) {
5777
- if (f) throw new TypeError("Generator is already executing.");
5778
-
5779
- while (_) {
5780
- try {
5781
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
5782
- if (y = 0, t) op = [op[0] & 2, t.value];
5783
-
5784
- switch (op[0]) {
5785
- case 0:
5786
- case 1:
5787
- t = op;
5788
- break;
5789
-
5790
- case 4:
5791
- _.label++;
5792
- return {
5793
- value: op[1],
5794
- done: false
5795
- };
5796
-
5797
- case 5:
5798
- _.label++;
5799
- y = op[1];
5800
- op = [0];
5801
- continue;
5802
-
5803
- case 7:
5804
- op = _.ops.pop();
5805
-
5806
- _.trys.pop();
5807
-
5808
- continue;
5809
-
5810
- default:
5811
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
5812
- _ = 0;
5813
- continue;
5814
- }
5815
-
5816
- if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
5817
- _.label = op[1];
5818
- break;
5819
- }
5820
-
5821
- if (op[0] === 6 && _.label < t[1]) {
5822
- _.label = t[1];
5823
- t = op;
5824
- break;
5825
- }
5826
-
5827
- if (t && _.label < t[2]) {
5828
- _.label = t[2];
5829
-
5830
- _.ops.push(op);
5831
-
5832
- break;
5833
- }
5834
-
5835
- if (t[2]) _.ops.pop();
5836
-
5837
- _.trys.pop();
5838
-
5839
- continue;
5840
- }
5841
-
5842
- op = body.call(thisArg, _);
5843
- } catch (e) {
5844
- op = [6, e];
5845
- y = 0;
5846
- } finally {
5847
- f = t = 0;
5848
- }
5849
- }
5850
-
5851
- if (op[0] & 5) throw op[1];
5852
- return {
5853
- value: op[0] ? op[1] : void 0,
5854
- done: true
5855
- };
5856
- }
5857
- }
5858
- function __createBinding(o, m, k, k2) {
5859
- if (k2 === undefined) k2 = k;
5860
- o[k2] = m[k];
5861
- }
5862
- function __exportStar(m, exports) {
5863
- for (var p in m) {
5864
- if (p !== "default" && !exports.hasOwnProperty(p)) exports[p] = m[p];
5865
- }
5866
- }
5867
- function __values(o) {
5868
- var s = typeof Symbol === "function" && Symbol.iterator,
5869
- m = s && o[s],
5870
- i = 0;
5871
- if (m) return m.call(o);
5872
- if (o && typeof o.length === "number") return {
5873
- next: function next() {
5874
- if (o && i >= o.length) o = void 0;
5875
- return {
5876
- value: o && o[i++],
5877
- done: !o
5878
- };
5879
- }
5880
- };
5881
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
5882
- }
5883
- function __read(o, n) {
5884
- var m = typeof Symbol === "function" && o[Symbol.iterator];
5885
- if (!m) return o;
5886
- var i = m.call(o),
5887
- r,
5888
- ar = [],
5889
- e;
5890
-
5891
- try {
5892
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) {
5893
- ar.push(r.value);
5894
- }
5895
- } catch (error) {
5896
- e = {
5897
- error: error
5898
- };
5899
- } finally {
5900
- try {
5901
- if (r && !r.done && (m = i["return"])) m.call(i);
5902
- } finally {
5903
- if (e) throw e.error;
5904
- }
5905
- }
5906
-
5907
- return ar;
5908
- }
5909
- function __spread() {
5910
- for (var ar = [], i = 0; i < arguments.length; i++) {
5911
- ar = ar.concat(__read(arguments[i]));
5912
- }
5913
-
5914
- return ar;
5915
- }
5916
- function __spreadArrays() {
5917
- for (var s = 0, i = 0, il = arguments.length; i < il; i++) {
5918
- s += arguments[i].length;
5919
- }
5920
-
5921
- for (var r = Array(s), k = 0, i = 0; i < il; i++) {
5922
- for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++) {
5923
- r[k] = a[j];
5924
- }
5925
- }
5926
-
5927
- return r;
5928
- }
5929
- function __await(v) {
5930
- return this instanceof __await ? (this.v = v, this) : new __await(v);
5931
- }
5932
- function __asyncGenerator(thisArg, _arguments, generator) {
5933
- if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
5934
- var g = generator.apply(thisArg, _arguments || []),
5935
- i,
5936
- q = [];
5937
- return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () {
5938
- return this;
5939
- }, i;
5940
-
5941
- function verb(n) {
5942
- if (g[n]) i[n] = function (v) {
5943
- return new Promise(function (a, b) {
5944
- q.push([n, v, a, b]) > 1 || resume(n, v);
5945
- });
5946
- };
5947
- }
5948
-
5949
- function resume(n, v) {
5950
- try {
5951
- step(g[n](v));
5952
- } catch (e) {
5953
- settle(q[0][3], e);
5954
- }
5955
- }
5956
-
5957
- function step(r) {
5958
- r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r);
5959
- }
5960
-
5961
- function fulfill(value) {
5962
- resume("next", value);
5963
- }
5964
-
5965
- function reject(value) {
5966
- resume("throw", value);
5967
- }
5968
-
5969
- function settle(f, v) {
5970
- if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]);
5971
- }
5972
- }
5973
- function __asyncDelegator(o) {
5974
- var i, p;
5975
- return i = {}, verb("next"), verb("throw", function (e) {
5976
- throw e;
5977
- }), verb("return"), i[Symbol.iterator] = function () {
5978
- return this;
5979
- }, i;
5980
-
5981
- function verb(n, f) {
5982
- i[n] = o[n] ? function (v) {
5983
- return (p = !p) ? {
5984
- value: __await(o[n](v)),
5985
- done: n === "return"
5986
- } : f ? f(v) : v;
5987
- } : f;
5988
- }
5989
- }
5990
- function __asyncValues(o) {
5991
- if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
5992
- var m = o[Symbol.asyncIterator],
5993
- i;
5994
- return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () {
5995
- return this;
5996
- }, i);
5997
-
5998
- function verb(n) {
5999
- i[n] = o[n] && function (v) {
6000
- return new Promise(function (resolve, reject) {
6001
- v = o[n](v), settle(resolve, reject, v.done, v.value);
6002
- });
6003
- };
6004
- }
6005
-
6006
- function settle(resolve, reject, d, v) {
6007
- Promise.resolve(v).then(function (v) {
6008
- resolve({
6009
- value: v,
6010
- done: d
6011
- });
6012
- }, reject);
6013
- }
6014
- }
6015
- function __makeTemplateObject(cooked, raw) {
6016
- if (Object.defineProperty) {
6017
- Object.defineProperty(cooked, "raw", {
6018
- value: raw
6019
- });
6020
- } else {
6021
- cooked.raw = raw;
6022
- }
6023
-
6024
- return cooked;
6025
- }
6026
- function __importStar(mod) {
6027
- if (mod && mod.__esModule) return mod;
6028
- var result = {};
6029
- if (mod != null) for (var k in mod) {
6030
- if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
6031
- }
6032
- result["default"] = mod;
6033
- return result;
6034
- }
6035
- function __importDefault(mod) {
6036
- return mod && mod.__esModule ? mod : {
6037
- "default": mod
6038
- };
6039
- }
6040
- function __classPrivateFieldGet(receiver, privateMap) {
6041
- if (!privateMap.has(receiver)) {
6042
- throw new TypeError("attempted to get private field on non-instance");
6043
- }
6044
-
6045
- return privateMap.get(receiver);
6046
- }
6047
- function __classPrivateFieldSet(receiver, privateMap, value) {
6048
- if (!privateMap.has(receiver)) {
6049
- throw new TypeError("attempted to set private field on non-instance");
6050
- }
6051
-
6052
- privateMap.set(receiver, value);
6053
- return value;
6054
- }
6055
-
6056
- var tslib_es6 = /*#__PURE__*/Object.freeze({
6057
- __proto__: null,
6058
- __extends: __extends,
6059
- get __assign () { return _assign; },
6060
- __rest: __rest,
6061
- __decorate: __decorate,
6062
- __param: __param,
6063
- __metadata: __metadata,
6064
- __awaiter: __awaiter,
6065
- __generator: __generator,
6066
- __createBinding: __createBinding,
6067
- __exportStar: __exportStar,
6068
- __values: __values,
6069
- __read: __read,
6070
- __spread: __spread,
6071
- __spreadArrays: __spreadArrays,
6072
- __await: __await,
6073
- __asyncGenerator: __asyncGenerator,
6074
- __asyncDelegator: __asyncDelegator,
6075
- __asyncValues: __asyncValues,
6076
- __makeTemplateObject: __makeTemplateObject,
6077
- __importStar: __importStar,
6078
- __importDefault: __importDefault,
6079
- __classPrivateFieldGet: __classPrivateFieldGet,
6080
- __classPrivateFieldSet: __classPrivateFieldSet
6081
- });
6082
-
6083
- var timestamp = createCommonjsModule(function (module, exports) {
6084
- Object.defineProperty(exports, "__esModule", { value: true });
6085
- exports.Timestamp = exports.LongWithoutOverridesClass = void 0;
6086
-
6087
-
6088
4879
  /** @public */
6089
- exports.LongWithoutOverridesClass = long_1.Long;
4880
+ var LongWithoutOverridesClass = Long;
6090
4881
  /** @public */
6091
4882
  var Timestamp = /** @class */ (function (_super) {
6092
- tslib_es6.__extends(Timestamp, _super);
4883
+ __extends(Timestamp, _super);
6093
4884
  function Timestamp(low, high) {
6094
4885
  var _this = this;
6095
4886
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
6096
4887
  ///@ts-expect-error
6097
4888
  if (!(_this instanceof Timestamp))
6098
4889
  return new Timestamp(low, high);
6099
- if (long_1.Long.isLong(low)) {
4890
+ if (Long.isLong(low)) {
6100
4891
  _this = _super.call(this, low.low, low.high, true) || this;
6101
4892
  }
4893
+ else if (isObjectLike(low) && typeof low.t !== 'undefined' && typeof low.i !== 'undefined') {
4894
+ _this = _super.call(this, low.i, low.t, true) || this;
4895
+ }
6102
4896
  else {
6103
4897
  _this = _super.call(this, low, high, true) || this;
6104
4898
  }
@@ -6117,11 +4911,11 @@ var BSON = (function (exports) {
6117
4911
  };
6118
4912
  /** Returns a Timestamp represented by the given (32-bit) integer value. */
6119
4913
  Timestamp.fromInt = function (value) {
6120
- return new Timestamp(long_1.Long.fromInt(value, true));
4914
+ return new Timestamp(Long.fromInt(value, true));
6121
4915
  };
6122
4916
  /** Returns a Timestamp representing the given number value, provided that it is a finite number. Otherwise, zero is returned. */
6123
4917
  Timestamp.fromNumber = function (value) {
6124
- return new Timestamp(long_1.Long.fromNumber(value, true));
4918
+ return new Timestamp(Long.fromNumber(value, true));
6125
4919
  };
6126
4920
  /**
6127
4921
  * Returns a Timestamp for the given high and low bits. Each is assumed to use 32 bits.
@@ -6139,7 +4933,7 @@ var BSON = (function (exports) {
6139
4933
  * @param optRadix - the radix in which the text is written.
6140
4934
  */
6141
4935
  Timestamp.fromString = function (str, optRadix) {
6142
- return new Timestamp(long_1.Long.fromString(str, true, optRadix));
4936
+ return new Timestamp(Long.fromString(str, true, optRadix));
6143
4937
  };
6144
4938
  /** @internal */
6145
4939
  Timestamp.prototype.toExtendedJSON = function () {
@@ -6147,69 +4941,44 @@ var BSON = (function (exports) {
6147
4941
  };
6148
4942
  /** @internal */
6149
4943
  Timestamp.fromExtendedJSON = function (doc) {
6150
- return new Timestamp(doc.$timestamp.i, doc.$timestamp.t);
4944
+ return new Timestamp(doc.$timestamp);
6151
4945
  };
6152
4946
  /** @internal */
6153
4947
  Timestamp.prototype[Symbol.for('nodejs.util.inspect.custom')] = function () {
6154
4948
  return this.inspect();
6155
4949
  };
6156
4950
  Timestamp.prototype.inspect = function () {
6157
- return "new Timestamp(" + this.getLowBits().toString() + ", " + this.getHighBits().toString() + ")";
4951
+ return "new Timestamp({ t: " + this.getHighBits() + ", i: " + this.getLowBits() + " })";
6158
4952
  };
6159
- Timestamp.MAX_VALUE = long_1.Long.MAX_UNSIGNED_VALUE;
4953
+ Timestamp.MAX_VALUE = Long.MAX_UNSIGNED_VALUE;
6160
4954
  return Timestamp;
6161
- }(exports.LongWithoutOverridesClass));
6162
- exports.Timestamp = Timestamp;
6163
- //# sourceMappingURL=timestamp.js.map
6164
- });
6165
-
6166
- unwrapExports(timestamp);
6167
- timestamp.Timestamp;
6168
- timestamp.LongWithoutOverridesClass;
6169
-
6170
- var extended_json = createCommonjsModule(function (module, exports) {
6171
- Object.defineProperty(exports, "__esModule", { value: true });
6172
- exports.EJSON = exports.isBSONType = void 0;
6173
-
6174
-
6175
-
6176
-
6177
-
6178
-
6179
-
6180
-
6181
-
6182
-
6183
-
6184
-
6185
-
4955
+ }(LongWithoutOverridesClass));
6186
4956
 
6187
4957
  function isBSONType(value) {
6188
- return (utils.isObjectLike(value) && Reflect.has(value, '_bsontype') && typeof value._bsontype === 'string');
4958
+ return (isObjectLike(value) && Reflect.has(value, '_bsontype') && typeof value._bsontype === 'string');
6189
4959
  }
6190
- exports.isBSONType = isBSONType;
6191
4960
  // INT32 boundaries
6192
- var BSON_INT32_MAX = 0x7fffffff;
6193
- var BSON_INT32_MIN = -0x80000000;
4961
+ var BSON_INT32_MAX$1 = 0x7fffffff;
4962
+ var BSON_INT32_MIN$1 = -0x80000000;
6194
4963
  // INT64 boundaries
6195
- var BSON_INT64_MAX = 0x7fffffffffffffff;
6196
- var BSON_INT64_MIN = -0x8000000000000000;
4964
+ var BSON_INT64_MAX$1 = 0x7fffffffffffffff;
4965
+ var BSON_INT64_MIN$1 = -0x8000000000000000;
6197
4966
  // all the types where we don't need to do any special processing and can just pass the EJSON
6198
4967
  //straight to type.fromExtendedJSON
6199
4968
  var keysToCodecs = {
6200
- $oid: objectid.ObjectId,
6201
- $binary: binary.Binary,
6202
- $uuid: binary.Binary,
6203
- $symbol: symbol.BSONSymbol,
6204
- $numberInt: int_32.Int32,
6205
- $numberDecimal: decimal128.Decimal128,
6206
- $numberDouble: double_1.Double,
6207
- $numberLong: long_1.Long,
6208
- $minKey: min_key.MinKey,
6209
- $maxKey: max_key.MaxKey,
6210
- $regex: regexp.BSONRegExp,
6211
- $regularExpression: regexp.BSONRegExp,
6212
- $timestamp: timestamp.Timestamp
4969
+ $oid: ObjectId,
4970
+ $binary: Binary,
4971
+ $uuid: Binary,
4972
+ $symbol: BSONSymbol,
4973
+ $numberInt: Int32,
4974
+ $numberDecimal: Decimal128,
4975
+ $numberDouble: Double,
4976
+ $numberLong: Long,
4977
+ $minKey: MinKey,
4978
+ $maxKey: MaxKey,
4979
+ $regex: BSONRegExp,
4980
+ $regularExpression: BSONRegExp,
4981
+ $timestamp: Timestamp
6213
4982
  };
6214
4983
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
6215
4984
  function deserializeValue(value, options) {
@@ -6221,13 +4990,13 @@ var BSON = (function (exports) {
6221
4990
  // if it's an integer, should interpret as smallest BSON integer
6222
4991
  // that can represent it exactly. (if out of range, interpret as double.)
6223
4992
  if (Math.floor(value) === value) {
6224
- if (value >= BSON_INT32_MIN && value <= BSON_INT32_MAX)
6225
- return new int_32.Int32(value);
6226
- if (value >= BSON_INT64_MIN && value <= BSON_INT64_MAX)
6227
- return long_1.Long.fromNumber(value);
4993
+ if (value >= BSON_INT32_MIN$1 && value <= BSON_INT32_MAX$1)
4994
+ return new Int32(value);
4995
+ if (value >= BSON_INT64_MIN$1 && value <= BSON_INT64_MAX$1)
4996
+ return Long.fromNumber(value);
6228
4997
  }
6229
4998
  // If the number is a non-integer or out of integer range, should interpret as BSON Double.
6230
- return new double_1.Double(value);
4999
+ return new Double(value);
6231
5000
  }
6232
5001
  // from here on out we're looking for bson types, so bail if its not an object
6233
5002
  if (value == null || typeof value !== 'object')
@@ -6253,7 +5022,7 @@ var BSON = (function (exports) {
6253
5022
  else {
6254
5023
  if (typeof d === 'string')
6255
5024
  date.setTime(Date.parse(d));
6256
- else if (long_1.Long.isLong(d))
5025
+ else if (Long.isLong(d))
6257
5026
  date.setTime(d.toNumber());
6258
5027
  else if (typeof d === 'number' && options.relaxed)
6259
5028
  date.setTime(d);
@@ -6265,13 +5034,13 @@ var BSON = (function (exports) {
6265
5034
  if (value.$scope) {
6266
5035
  copy.$scope = deserializeValue(value.$scope);
6267
5036
  }
6268
- return code.Code.fromExtendedJSON(value);
5037
+ return Code.fromExtendedJSON(value);
6269
5038
  }
6270
- if (value.$ref != null || value.$dbPointer != null) {
5039
+ if (isDBRefLike(value) || value.$dbPointer) {
6271
5040
  var v = value.$ref ? value : value.$dbPointer;
6272
5041
  // we run into this in a "degenerate EJSON" case (with $id and $ref order flipped)
6273
5042
  // because of the order JSON.parse goes through the document
6274
- if (v instanceof db_ref.DBRef)
5043
+ if (v instanceof DBRef)
6275
5044
  return v;
6276
5045
  var dollarKeys = Object.keys(v).filter(function (k) { return k.startsWith('$'); });
6277
5046
  var valid_1 = true;
@@ -6281,7 +5050,7 @@ var BSON = (function (exports) {
6281
5050
  });
6282
5051
  // only make DBRef if $ keys are all valid
6283
5052
  if (valid_1)
6284
- return db_ref.DBRef.fromExtendedJSON(v);
5053
+ return DBRef.fromExtendedJSON(v);
6285
5054
  }
6286
5055
  return value;
6287
5056
  }
@@ -6331,7 +5100,7 @@ var BSON = (function (exports) {
6331
5100
  return serializeArray(value, options);
6332
5101
  if (value === undefined)
6333
5102
  return null;
6334
- if (value instanceof Date || utils.isDate(value)) {
5103
+ if (value instanceof Date || isDate(value)) {
6335
5104
  var dateNum = value.getTime(),
6336
5105
  // is it in year range 1970-9999?
6337
5106
  inRange = dateNum > -1 && dateNum < 253402318800000;
@@ -6344,10 +5113,10 @@ var BSON = (function (exports) {
6344
5113
  ? { $date: getISOString(value) }
6345
5114
  : { $date: { $numberLong: value.getTime().toString() } };
6346
5115
  }
6347
- if (typeof value === 'number' && !options.relaxed) {
5116
+ if (typeof value === 'number' && (!options.relaxed || !isFinite(value))) {
6348
5117
  // it's an integer
6349
5118
  if (Math.floor(value) === value) {
6350
- var int32Range = value >= BSON_INT32_MIN && value <= BSON_INT32_MAX, int64Range = value >= BSON_INT64_MIN && value <= BSON_INT64_MAX;
5119
+ var int32Range = value >= BSON_INT32_MIN$1 && value <= BSON_INT32_MAX$1, int64Range = value >= BSON_INT64_MIN$1 && value <= BSON_INT64_MAX$1;
6351
5120
  // interpret as being of the smallest BSON integer type that can represent the number exactly
6352
5121
  if (int32Range)
6353
5122
  return { $numberInt: value.toString() };
@@ -6356,7 +5125,7 @@ var BSON = (function (exports) {
6356
5125
  }
6357
5126
  return { $numberDouble: value.toString() };
6358
5127
  }
6359
- if (value instanceof RegExp || utils.isRegExp(value)) {
5128
+ if (value instanceof RegExp || isRegExp(value)) {
6360
5129
  var flags = value.flags;
6361
5130
  if (flags === undefined) {
6362
5131
  var match = value.toString().match(/[gimuy]*$/);
@@ -6364,7 +5133,7 @@ var BSON = (function (exports) {
6364
5133
  flags = match[0];
6365
5134
  }
6366
5135
  }
6367
- var rx = new regexp.BSONRegExp(value.source, flags);
5136
+ var rx = new BSONRegExp(value.source, flags);
6368
5137
  return rx.toExtendedJSON(options);
6369
5138
  }
6370
5139
  if (value != null && typeof value === 'object')
@@ -6372,24 +5141,24 @@ var BSON = (function (exports) {
6372
5141
  return value;
6373
5142
  }
6374
5143
  var BSON_TYPE_MAPPINGS = {
6375
- Binary: function (o) { return new binary.Binary(o.value(), o.sub_type); },
6376
- Code: function (o) { return new code.Code(o.code, o.scope); },
6377
- DBRef: function (o) { return new db_ref.DBRef(o.collection || o.namespace, o.oid, o.db, o.fields); },
6378
- Decimal128: function (o) { return new decimal128.Decimal128(o.bytes); },
6379
- Double: function (o) { return new double_1.Double(o.value); },
6380
- Int32: function (o) { return new int_32.Int32(o.value); },
5144
+ Binary: function (o) { return new Binary(o.value(), o.sub_type); },
5145
+ Code: function (o) { return new Code(o.code, o.scope); },
5146
+ DBRef: function (o) { return new DBRef(o.collection || o.namespace, o.oid, o.db, o.fields); },
5147
+ Decimal128: function (o) { return new Decimal128(o.bytes); },
5148
+ Double: function (o) { return new Double(o.value); },
5149
+ Int32: function (o) { return new Int32(o.value); },
6381
5150
  Long: function (o) {
6382
- return long_1.Long.fromBits(
5151
+ return Long.fromBits(
6383
5152
  // underscore variants for 1.x backwards compatibility
6384
5153
  o.low != null ? o.low : o.low_, o.low != null ? o.high : o.high_, o.low != null ? o.unsigned : o.unsigned_);
6385
5154
  },
6386
- MaxKey: function () { return new max_key.MaxKey(); },
6387
- MinKey: function () { return new min_key.MinKey(); },
6388
- ObjectID: function (o) { return new objectid.ObjectId(o); },
6389
- ObjectId: function (o) { return new objectid.ObjectId(o); },
6390
- BSONRegExp: function (o) { return new regexp.BSONRegExp(o.pattern, o.options); },
6391
- Symbol: function (o) { return new symbol.BSONSymbol(o.value); },
6392
- Timestamp: function (o) { return timestamp.Timestamp.fromBits(o.low, o.high); }
5155
+ MaxKey: function () { return new MaxKey(); },
5156
+ MinKey: function () { return new MinKey(); },
5157
+ ObjectID: function (o) { return new ObjectId(o); },
5158
+ ObjectId: function (o) { return new ObjectId(o); },
5159
+ BSONRegExp: function (o) { return new BSONRegExp(o.pattern, o.options); },
5160
+ Symbol: function (o) { return new BSONSymbol(o.value); },
5161
+ Timestamp: function (o) { return Timestamp.fromBits(o.low, o.high); }
6393
5162
  };
6394
5163
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
6395
5164
  function serializeDocument(doc, options) {
@@ -6427,10 +5196,10 @@ var BSON = (function (exports) {
6427
5196
  }
6428
5197
  // Two BSON types may have nested objects that may need to be serialized too
6429
5198
  if (bsontype === 'Code' && outDoc.scope) {
6430
- outDoc = new code.Code(outDoc.code, serializeValue(outDoc.scope, options));
5199
+ outDoc = new Code(outDoc.code, serializeValue(outDoc.scope, options));
6431
5200
  }
6432
5201
  else if (bsontype === 'DBRef' && outDoc.oid) {
6433
- outDoc = new db_ref.DBRef(outDoc.collection, serializeValue(outDoc.oid, options), outDoc.db, outDoc.fields);
5202
+ outDoc = new DBRef(serializeValue(outDoc.collection, options), serializeValue(outDoc.oid, options), serializeValue(outDoc.db, options), serializeValue(outDoc.fields, options));
6434
5203
  }
6435
5204
  return outDoc.toExtendedJSON(options);
6436
5205
  }
@@ -6438,6 +5207,14 @@ var BSON = (function (exports) {
6438
5207
  throw new Error('_bsontype must be a string, but was: ' + typeof bsontype);
6439
5208
  }
6440
5209
  }
5210
+ /**
5211
+ * EJSON parse / stringify API
5212
+ * @public
5213
+ */
5214
+ // the namespace here is used to emulate `export * as EJSON from '...'`
5215
+ // which as of now (sept 2020) api-extractor does not support
5216
+ // eslint-disable-next-line @typescript-eslint/no-namespace
5217
+ exports.EJSON = void 0;
6441
5218
  (function (EJSON) {
6442
5219
  /**
6443
5220
  * Parse an Extended JSON string, constructing the JavaScript value or object described by that
@@ -6530,41 +5307,17 @@ var BSON = (function (exports) {
6530
5307
  }
6531
5308
  EJSON.deserialize = deserialize;
6532
5309
  })(exports.EJSON || (exports.EJSON = {}));
6533
- //# sourceMappingURL=extended_json.js.map
6534
- });
6535
-
6536
- unwrapExports(extended_json);
6537
- extended_json.EJSON;
6538
- extended_json.isBSONType;
6539
5310
 
6540
- var map = createCommonjsModule(function (module, exports) {
6541
5311
  /* eslint-disable @typescript-eslint/no-explicit-any */
6542
- // We have an ES6 Map available, return the native instance
6543
- Object.defineProperty(exports, "__esModule", { value: true });
6544
- exports.Map = void 0;
6545
5312
  /** @public */
6546
- var bsonMap;
6547
- exports.Map = bsonMap;
6548
- var check = function (potentialGlobal) {
6549
- // eslint-disable-next-line eqeqeq
6550
- return potentialGlobal && potentialGlobal.Math == Math && potentialGlobal;
6551
- };
6552
- // https://github.com/zloirock/core-js/issues/86#issuecomment-115759028
6553
- function getGlobal() {
6554
- // eslint-disable-next-line no-undef
6555
- return (check(typeof globalThis === 'object' && globalThis) ||
6556
- check(typeof window === 'object' && window) ||
6557
- check(typeof self === 'object' && self) ||
6558
- check(typeof commonjsGlobal === 'object' && commonjsGlobal) ||
6559
- Function('return this')());
6560
- }
5313
+ exports.Map = void 0;
6561
5314
  var bsonGlobal = getGlobal();
6562
- if (Object.prototype.hasOwnProperty.call(bsonGlobal, 'Map')) {
6563
- exports.Map = bsonMap = bsonGlobal.Map;
5315
+ if (bsonGlobal.Map) {
5316
+ exports.Map = bsonGlobal.Map;
6564
5317
  }
6565
5318
  else {
6566
5319
  // We will return a polyfill
6567
- exports.Map = bsonMap = /** @class */ (function () {
5320
+ exports.Map = /** @class */ (function () {
6568
5321
  function Map(array) {
6569
5322
  if (array === void 0) { array = []; }
6570
5323
  this._keys = [];
@@ -6671,136 +5424,83 @@ var BSON = (function (exports) {
6671
5424
  return Map;
6672
5425
  }());
6673
5426
  }
6674
- //# sourceMappingURL=map.js.map
6675
- });
6676
5427
 
6677
- unwrapExports(map);
6678
- map.Map;
6679
-
6680
- var constants = createCommonjsModule(function (module, exports) {
6681
- Object.defineProperty(exports, "__esModule", { value: true });
6682
- exports.BSON_BINARY_SUBTYPE_USER_DEFINED = exports.BSON_BINARY_SUBTYPE_MD5 = exports.BSON_BINARY_SUBTYPE_UUID_NEW = exports.BSON_BINARY_SUBTYPE_UUID = exports.BSON_BINARY_SUBTYPE_BYTE_ARRAY = exports.BSON_BINARY_SUBTYPE_FUNCTION = exports.BSON_BINARY_SUBTYPE_DEFAULT = exports.BSON_DATA_MAX_KEY = exports.BSON_DATA_MIN_KEY = exports.BSON_DATA_DECIMAL128 = exports.BSON_DATA_LONG = exports.BSON_DATA_TIMESTAMP = exports.BSON_DATA_INT = exports.BSON_DATA_CODE_W_SCOPE = exports.BSON_DATA_SYMBOL = exports.BSON_DATA_CODE = exports.BSON_DATA_DBPOINTER = exports.BSON_DATA_REGEXP = exports.BSON_DATA_NULL = exports.BSON_DATA_DATE = exports.BSON_DATA_BOOLEAN = exports.BSON_DATA_OID = exports.BSON_DATA_UNDEFINED = exports.BSON_DATA_BINARY = exports.BSON_DATA_ARRAY = exports.BSON_DATA_OBJECT = exports.BSON_DATA_STRING = exports.BSON_DATA_NUMBER = exports.JS_INT_MIN = exports.JS_INT_MAX = exports.BSON_INT64_MIN = exports.BSON_INT64_MAX = exports.BSON_INT32_MIN = exports.BSON_INT32_MAX = void 0;
6683
5428
  /** @internal */
6684
- exports.BSON_INT32_MAX = 0x7fffffff;
5429
+ var BSON_INT32_MAX = 0x7fffffff;
6685
5430
  /** @internal */
6686
- exports.BSON_INT32_MIN = -0x80000000;
5431
+ var BSON_INT32_MIN = -0x80000000;
6687
5432
  /** @internal */
6688
- exports.BSON_INT64_MAX = Math.pow(2, 63) - 1;
5433
+ var BSON_INT64_MAX = Math.pow(2, 63) - 1;
6689
5434
  /** @internal */
6690
- exports.BSON_INT64_MIN = -Math.pow(2, 63);
5435
+ var BSON_INT64_MIN = -Math.pow(2, 63);
6691
5436
  /**
6692
5437
  * Any integer up to 2^53 can be precisely represented by a double.
6693
5438
  * @internal
6694
5439
  */
6695
- exports.JS_INT_MAX = Math.pow(2, 53);
5440
+ var JS_INT_MAX = Math.pow(2, 53);
6696
5441
  /**
6697
5442
  * Any integer down to -2^53 can be precisely represented by a double.
6698
5443
  * @internal
6699
5444
  */
6700
- exports.JS_INT_MIN = -Math.pow(2, 53);
5445
+ var JS_INT_MIN = -Math.pow(2, 53);
6701
5446
  /** Number BSON Type @internal */
6702
- exports.BSON_DATA_NUMBER = 1;
5447
+ var BSON_DATA_NUMBER = 1;
6703
5448
  /** String BSON Type @internal */
6704
- exports.BSON_DATA_STRING = 2;
5449
+ var BSON_DATA_STRING = 2;
6705
5450
  /** Object BSON Type @internal */
6706
- exports.BSON_DATA_OBJECT = 3;
5451
+ var BSON_DATA_OBJECT = 3;
6707
5452
  /** Array BSON Type @internal */
6708
- exports.BSON_DATA_ARRAY = 4;
5453
+ var BSON_DATA_ARRAY = 4;
6709
5454
  /** Binary BSON Type @internal */
6710
- exports.BSON_DATA_BINARY = 5;
5455
+ var BSON_DATA_BINARY = 5;
6711
5456
  /** Binary BSON Type @internal */
6712
- exports.BSON_DATA_UNDEFINED = 6;
5457
+ var BSON_DATA_UNDEFINED = 6;
6713
5458
  /** ObjectId BSON Type @internal */
6714
- exports.BSON_DATA_OID = 7;
5459
+ var BSON_DATA_OID = 7;
6715
5460
  /** Boolean BSON Type @internal */
6716
- exports.BSON_DATA_BOOLEAN = 8;
5461
+ var BSON_DATA_BOOLEAN = 8;
6717
5462
  /** Date BSON Type @internal */
6718
- exports.BSON_DATA_DATE = 9;
5463
+ var BSON_DATA_DATE = 9;
6719
5464
  /** null BSON Type @internal */
6720
- exports.BSON_DATA_NULL = 10;
5465
+ var BSON_DATA_NULL = 10;
6721
5466
  /** RegExp BSON Type @internal */
6722
- exports.BSON_DATA_REGEXP = 11;
5467
+ var BSON_DATA_REGEXP = 11;
6723
5468
  /** Code BSON Type @internal */
6724
- exports.BSON_DATA_DBPOINTER = 12;
5469
+ var BSON_DATA_DBPOINTER = 12;
6725
5470
  /** Code BSON Type @internal */
6726
- exports.BSON_DATA_CODE = 13;
5471
+ var BSON_DATA_CODE = 13;
6727
5472
  /** Symbol BSON Type @internal */
6728
- exports.BSON_DATA_SYMBOL = 14;
5473
+ var BSON_DATA_SYMBOL = 14;
6729
5474
  /** Code with Scope BSON Type @internal */
6730
- exports.BSON_DATA_CODE_W_SCOPE = 15;
5475
+ var BSON_DATA_CODE_W_SCOPE = 15;
6731
5476
  /** 32 bit Integer BSON Type @internal */
6732
- exports.BSON_DATA_INT = 16;
5477
+ var BSON_DATA_INT = 16;
6733
5478
  /** Timestamp BSON Type @internal */
6734
- exports.BSON_DATA_TIMESTAMP = 17;
5479
+ var BSON_DATA_TIMESTAMP = 17;
6735
5480
  /** Long BSON Type @internal */
6736
- exports.BSON_DATA_LONG = 18;
5481
+ var BSON_DATA_LONG = 18;
6737
5482
  /** Decimal128 BSON Type @internal */
6738
- exports.BSON_DATA_DECIMAL128 = 19;
5483
+ var BSON_DATA_DECIMAL128 = 19;
6739
5484
  /** MinKey BSON Type @internal */
6740
- exports.BSON_DATA_MIN_KEY = 0xff;
5485
+ var BSON_DATA_MIN_KEY = 0xff;
6741
5486
  /** MaxKey BSON Type @internal */
6742
- exports.BSON_DATA_MAX_KEY = 0x7f;
5487
+ var BSON_DATA_MAX_KEY = 0x7f;
6743
5488
  /** Binary Default Type @internal */
6744
- exports.BSON_BINARY_SUBTYPE_DEFAULT = 0;
5489
+ var BSON_BINARY_SUBTYPE_DEFAULT = 0;
6745
5490
  /** Binary Function Type @internal */
6746
- exports.BSON_BINARY_SUBTYPE_FUNCTION = 1;
5491
+ var BSON_BINARY_SUBTYPE_FUNCTION = 1;
6747
5492
  /** Binary Byte Array Type @internal */
6748
- exports.BSON_BINARY_SUBTYPE_BYTE_ARRAY = 2;
5493
+ var BSON_BINARY_SUBTYPE_BYTE_ARRAY = 2;
6749
5494
  /** Binary Deprecated UUID Type @deprecated Please use BSON_BINARY_SUBTYPE_UUID_NEW @internal */
6750
- exports.BSON_BINARY_SUBTYPE_UUID = 3;
5495
+ var BSON_BINARY_SUBTYPE_UUID = 3;
6751
5496
  /** Binary UUID Type @internal */
6752
- exports.BSON_BINARY_SUBTYPE_UUID_NEW = 4;
5497
+ var BSON_BINARY_SUBTYPE_UUID_NEW = 4;
6753
5498
  /** Binary MD5 Type @internal */
6754
- exports.BSON_BINARY_SUBTYPE_MD5 = 5;
5499
+ var BSON_BINARY_SUBTYPE_MD5 = 5;
6755
5500
  /** Binary User Defined Type @internal */
6756
- exports.BSON_BINARY_SUBTYPE_USER_DEFINED = 128;
6757
- //# sourceMappingURL=constants.js.map
6758
- });
5501
+ var BSON_BINARY_SUBTYPE_USER_DEFINED = 128;
6759
5502
 
6760
- unwrapExports(constants);
6761
- constants.BSON_BINARY_SUBTYPE_USER_DEFINED;
6762
- constants.BSON_BINARY_SUBTYPE_MD5;
6763
- constants.BSON_BINARY_SUBTYPE_UUID_NEW;
6764
- constants.BSON_BINARY_SUBTYPE_UUID;
6765
- constants.BSON_BINARY_SUBTYPE_BYTE_ARRAY;
6766
- constants.BSON_BINARY_SUBTYPE_FUNCTION;
6767
- constants.BSON_BINARY_SUBTYPE_DEFAULT;
6768
- constants.BSON_DATA_MAX_KEY;
6769
- constants.BSON_DATA_MIN_KEY;
6770
- constants.BSON_DATA_DECIMAL128;
6771
- constants.BSON_DATA_LONG;
6772
- constants.BSON_DATA_TIMESTAMP;
6773
- constants.BSON_DATA_INT;
6774
- constants.BSON_DATA_CODE_W_SCOPE;
6775
- constants.BSON_DATA_SYMBOL;
6776
- constants.BSON_DATA_CODE;
6777
- constants.BSON_DATA_DBPOINTER;
6778
- constants.BSON_DATA_REGEXP;
6779
- constants.BSON_DATA_NULL;
6780
- constants.BSON_DATA_DATE;
6781
- constants.BSON_DATA_BOOLEAN;
6782
- constants.BSON_DATA_OID;
6783
- constants.BSON_DATA_UNDEFINED;
6784
- constants.BSON_DATA_BINARY;
6785
- constants.BSON_DATA_ARRAY;
6786
- constants.BSON_DATA_OBJECT;
6787
- constants.BSON_DATA_STRING;
6788
- constants.BSON_DATA_NUMBER;
6789
- constants.JS_INT_MIN;
6790
- constants.JS_INT_MAX;
6791
- constants.BSON_INT64_MIN;
6792
- constants.BSON_INT64_MAX;
6793
- constants.BSON_INT32_MIN;
6794
- constants.BSON_INT32_MAX;
6795
-
6796
- var calculate_size = createCommonjsModule(function (module, exports) {
6797
- Object.defineProperty(exports, "__esModule", { value: true });
6798
- exports.calculateObjectSize = void 0;
6799
-
6800
-
6801
-
6802
-
6803
- function calculateObjectSize(object, serializeFunctions, ignoreUndefined) {
5503
+ function calculateObjectSize$1(object, serializeFunctions, ignoreUndefined) {
6804
5504
  var totalLength = 4 + 1;
6805
5505
  if (Array.isArray(object)) {
6806
5506
  for (var i = 0; i < object.length; i++) {
@@ -6819,7 +5519,6 @@ var BSON = (function (exports) {
6819
5519
  }
6820
5520
  return totalLength;
6821
5521
  }
6822
- exports.calculateObjectSize = calculateObjectSize;
6823
5522
  /** @internal */
6824
5523
  function calculateElement(name,
6825
5524
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -6833,84 +5532,84 @@ var BSON = (function (exports) {
6833
5532
  }
6834
5533
  switch (typeof value) {
6835
5534
  case 'string':
6836
- return 1 + buffer.Buffer.byteLength(name, 'utf8') + 1 + 4 + buffer.Buffer.byteLength(value, 'utf8') + 1;
5535
+ return 1 + buffer_1.byteLength(name, 'utf8') + 1 + 4 + buffer_1.byteLength(value, 'utf8') + 1;
6837
5536
  case 'number':
6838
5537
  if (Math.floor(value) === value &&
6839
- value >= constants.JS_INT_MIN &&
6840
- value <= constants.JS_INT_MAX) {
6841
- if (value >= constants.BSON_INT32_MIN && value <= constants.BSON_INT32_MAX) {
5538
+ value >= JS_INT_MIN &&
5539
+ value <= JS_INT_MAX) {
5540
+ if (value >= BSON_INT32_MIN && value <= BSON_INT32_MAX) {
6842
5541
  // 32 bit
6843
- return (name != null ? buffer.Buffer.byteLength(name, 'utf8') + 1 : 0) + (4 + 1);
5542
+ return (name != null ? buffer_1.byteLength(name, 'utf8') + 1 : 0) + (4 + 1);
6844
5543
  }
6845
5544
  else {
6846
- return (name != null ? buffer.Buffer.byteLength(name, 'utf8') + 1 : 0) + (8 + 1);
5545
+ return (name != null ? buffer_1.byteLength(name, 'utf8') + 1 : 0) + (8 + 1);
6847
5546
  }
6848
5547
  }
6849
5548
  else {
6850
5549
  // 64 bit
6851
- return (name != null ? buffer.Buffer.byteLength(name, 'utf8') + 1 : 0) + (8 + 1);
5550
+ return (name != null ? buffer_1.byteLength(name, 'utf8') + 1 : 0) + (8 + 1);
6852
5551
  }
6853
5552
  case 'undefined':
6854
5553
  if (isArray || !ignoreUndefined)
6855
- return (name != null ? buffer.Buffer.byteLength(name, 'utf8') + 1 : 0) + 1;
5554
+ return (name != null ? buffer_1.byteLength(name, 'utf8') + 1 : 0) + 1;
6856
5555
  return 0;
6857
5556
  case 'boolean':
6858
- return (name != null ? buffer.Buffer.byteLength(name, 'utf8') + 1 : 0) + (1 + 1);
5557
+ return (name != null ? buffer_1.byteLength(name, 'utf8') + 1 : 0) + (1 + 1);
6859
5558
  case 'object':
6860
5559
  if (value == null || value['_bsontype'] === 'MinKey' || value['_bsontype'] === 'MaxKey') {
6861
- return (name != null ? buffer.Buffer.byteLength(name, 'utf8') + 1 : 0) + 1;
5560
+ return (name != null ? buffer_1.byteLength(name, 'utf8') + 1 : 0) + 1;
6862
5561
  }
6863
5562
  else if (value['_bsontype'] === 'ObjectId' || value['_bsontype'] === 'ObjectID') {
6864
- return (name != null ? buffer.Buffer.byteLength(name, 'utf8') + 1 : 0) + (12 + 1);
5563
+ return (name != null ? buffer_1.byteLength(name, 'utf8') + 1 : 0) + (12 + 1);
6865
5564
  }
6866
- else if (value instanceof Date || utils.isDate(value)) {
6867
- return (name != null ? buffer.Buffer.byteLength(name, 'utf8') + 1 : 0) + (8 + 1);
5565
+ else if (value instanceof Date || isDate(value)) {
5566
+ return (name != null ? buffer_1.byteLength(name, 'utf8') + 1 : 0) + (8 + 1);
6868
5567
  }
6869
5568
  else if (ArrayBuffer.isView(value) ||
6870
5569
  value instanceof ArrayBuffer ||
6871
- utils.isAnyArrayBuffer(value)) {
6872
- return ((name != null ? buffer.Buffer.byteLength(name, 'utf8') + 1 : 0) + (1 + 4 + 1) + value.byteLength);
5570
+ isAnyArrayBuffer(value)) {
5571
+ return ((name != null ? buffer_1.byteLength(name, 'utf8') + 1 : 0) + (1 + 4 + 1) + value.byteLength);
6873
5572
  }
6874
5573
  else if (value['_bsontype'] === 'Long' ||
6875
5574
  value['_bsontype'] === 'Double' ||
6876
5575
  value['_bsontype'] === 'Timestamp') {
6877
- return (name != null ? buffer.Buffer.byteLength(name, 'utf8') + 1 : 0) + (8 + 1);
5576
+ return (name != null ? buffer_1.byteLength(name, 'utf8') + 1 : 0) + (8 + 1);
6878
5577
  }
6879
5578
  else if (value['_bsontype'] === 'Decimal128') {
6880
- return (name != null ? buffer.Buffer.byteLength(name, 'utf8') + 1 : 0) + (16 + 1);
5579
+ return (name != null ? buffer_1.byteLength(name, 'utf8') + 1 : 0) + (16 + 1);
6881
5580
  }
6882
5581
  else if (value['_bsontype'] === 'Code') {
6883
5582
  // Calculate size depending on the availability of a scope
6884
5583
  if (value.scope != null && Object.keys(value.scope).length > 0) {
6885
- return ((name != null ? buffer.Buffer.byteLength(name, 'utf8') + 1 : 0) +
5584
+ return ((name != null ? buffer_1.byteLength(name, 'utf8') + 1 : 0) +
6886
5585
  1 +
6887
5586
  4 +
6888
5587
  4 +
6889
- buffer.Buffer.byteLength(value.code.toString(), 'utf8') +
5588
+ buffer_1.byteLength(value.code.toString(), 'utf8') +
6890
5589
  1 +
6891
- calculateObjectSize(value.scope, serializeFunctions, ignoreUndefined));
5590
+ calculateObjectSize$1(value.scope, serializeFunctions, ignoreUndefined));
6892
5591
  }
6893
5592
  else {
6894
- return ((name != null ? buffer.Buffer.byteLength(name, 'utf8') + 1 : 0) +
5593
+ return ((name != null ? buffer_1.byteLength(name, 'utf8') + 1 : 0) +
6895
5594
  1 +
6896
5595
  4 +
6897
- buffer.Buffer.byteLength(value.code.toString(), 'utf8') +
5596
+ buffer_1.byteLength(value.code.toString(), 'utf8') +
6898
5597
  1);
6899
5598
  }
6900
5599
  }
6901
5600
  else if (value['_bsontype'] === 'Binary') {
6902
5601
  // Check what kind of subtype we have
6903
- if (value.sub_type === binary.Binary.SUBTYPE_BYTE_ARRAY) {
6904
- return ((name != null ? buffer.Buffer.byteLength(name, 'utf8') + 1 : 0) +
5602
+ if (value.sub_type === Binary.SUBTYPE_BYTE_ARRAY) {
5603
+ return ((name != null ? buffer_1.byteLength(name, 'utf8') + 1 : 0) +
6905
5604
  (value.position + 1 + 4 + 1 + 4));
6906
5605
  }
6907
5606
  else {
6908
- return ((name != null ? buffer.Buffer.byteLength(name, 'utf8') + 1 : 0) + (value.position + 1 + 4 + 1));
5607
+ return ((name != null ? buffer_1.byteLength(name, 'utf8') + 1 : 0) + (value.position + 1 + 4 + 1));
6909
5608
  }
6910
5609
  }
6911
5610
  else if (value['_bsontype'] === 'Symbol') {
6912
- return ((name != null ? buffer.Buffer.byteLength(name, 'utf8') + 1 : 0) +
6913
- buffer.Buffer.byteLength(value.value, 'utf8') +
5611
+ return ((name != null ? buffer_1.byteLength(name, 'utf8') + 1 : 0) +
5612
+ buffer_1.byteLength(value.value, 'utf8') +
6914
5613
  4 +
6915
5614
  1 +
6916
5615
  1);
@@ -6925,14 +5624,14 @@ var BSON = (function (exports) {
6925
5624
  if (value.db != null) {
6926
5625
  ordered_values['$db'] = value.db;
6927
5626
  }
6928
- return ((name != null ? buffer.Buffer.byteLength(name, 'utf8') + 1 : 0) +
5627
+ return ((name != null ? buffer_1.byteLength(name, 'utf8') + 1 : 0) +
6929
5628
  1 +
6930
- calculateObjectSize(ordered_values, serializeFunctions, ignoreUndefined));
5629
+ calculateObjectSize$1(ordered_values, serializeFunctions, ignoreUndefined));
6931
5630
  }
6932
- else if (value instanceof RegExp || utils.isRegExp(value)) {
6933
- return ((name != null ? buffer.Buffer.byteLength(name, 'utf8') + 1 : 0) +
5631
+ else if (value instanceof RegExp || isRegExp(value)) {
5632
+ return ((name != null ? buffer_1.byteLength(name, 'utf8') + 1 : 0) +
6934
5633
  1 +
6935
- buffer.Buffer.byteLength(value.source, 'utf8') +
5634
+ buffer_1.byteLength(value.source, 'utf8') +
6936
5635
  1 +
6937
5636
  (value.global ? 1 : 0) +
6938
5637
  (value.ignoreCase ? 1 : 0) +
@@ -6940,24 +5639,24 @@ var BSON = (function (exports) {
6940
5639
  1);
6941
5640
  }
6942
5641
  else if (value['_bsontype'] === 'BSONRegExp') {
6943
- return ((name != null ? buffer.Buffer.byteLength(name, 'utf8') + 1 : 0) +
5642
+ return ((name != null ? buffer_1.byteLength(name, 'utf8') + 1 : 0) +
6944
5643
  1 +
6945
- buffer.Buffer.byteLength(value.pattern, 'utf8') +
5644
+ buffer_1.byteLength(value.pattern, 'utf8') +
6946
5645
  1 +
6947
- buffer.Buffer.byteLength(value.options, 'utf8') +
5646
+ buffer_1.byteLength(value.options, 'utf8') +
6948
5647
  1);
6949
5648
  }
6950
5649
  else {
6951
- return ((name != null ? buffer.Buffer.byteLength(name, 'utf8') + 1 : 0) +
6952
- calculateObjectSize(value, serializeFunctions, ignoreUndefined) +
5650
+ return ((name != null ? buffer_1.byteLength(name, 'utf8') + 1 : 0) +
5651
+ calculateObjectSize$1(value, serializeFunctions, ignoreUndefined) +
6953
5652
  1);
6954
5653
  }
6955
5654
  case 'function':
6956
5655
  // WTF for 0.4.X where typeof /someregexp/ === 'function'
6957
- if (value instanceof RegExp || utils.isRegExp(value) || String.call(value) === '[object RegExp]') {
6958
- return ((name != null ? buffer.Buffer.byteLength(name, 'utf8') + 1 : 0) +
5656
+ if (value instanceof RegExp || isRegExp(value) || String.call(value) === '[object RegExp]') {
5657
+ return ((name != null ? buffer_1.byteLength(name, 'utf8') + 1 : 0) +
6959
5658
  1 +
6960
- buffer.Buffer.byteLength(value.source, 'utf8') +
5659
+ buffer_1.byteLength(value.source, 'utf8') +
6961
5660
  1 +
6962
5661
  (value.global ? 1 : 0) +
6963
5662
  (value.ignoreCase ? 1 : 0) +
@@ -6966,34 +5665,26 @@ var BSON = (function (exports) {
6966
5665
  }
6967
5666
  else {
6968
5667
  if (serializeFunctions && value.scope != null && Object.keys(value.scope).length > 0) {
6969
- return ((name != null ? buffer.Buffer.byteLength(name, 'utf8') + 1 : 0) +
5668
+ return ((name != null ? buffer_1.byteLength(name, 'utf8') + 1 : 0) +
6970
5669
  1 +
6971
5670
  4 +
6972
5671
  4 +
6973
- buffer.Buffer.byteLength(utils.normalizedFunctionString(value), 'utf8') +
5672
+ buffer_1.byteLength(normalizedFunctionString(value), 'utf8') +
6974
5673
  1 +
6975
- calculateObjectSize(value.scope, serializeFunctions, ignoreUndefined));
5674
+ calculateObjectSize$1(value.scope, serializeFunctions, ignoreUndefined));
6976
5675
  }
6977
5676
  else if (serializeFunctions) {
6978
- return ((name != null ? buffer.Buffer.byteLength(name, 'utf8') + 1 : 0) +
5677
+ return ((name != null ? buffer_1.byteLength(name, 'utf8') + 1 : 0) +
6979
5678
  1 +
6980
5679
  4 +
6981
- buffer.Buffer.byteLength(utils.normalizedFunctionString(value), 'utf8') +
5680
+ buffer_1.byteLength(normalizedFunctionString(value), 'utf8') +
6982
5681
  1);
6983
5682
  }
6984
5683
  }
6985
5684
  }
6986
5685
  return 0;
6987
5686
  }
6988
- //# sourceMappingURL=calculate_size.js.map
6989
- });
6990
-
6991
- unwrapExports(calculate_size);
6992
- calculate_size.calculateObjectSize;
6993
5687
 
6994
- var validate_utf8 = createCommonjsModule(function (module, exports) {
6995
- Object.defineProperty(exports, "__esModule", { value: true });
6996
- exports.validateUtf8 = void 0;
6997
5688
  var FIRST_BIT = 0x80;
6998
5689
  var FIRST_TWO_BITS = 0xc0;
6999
5690
  var FIRST_THREE_BITS = 0xe0;
@@ -7036,37 +5727,12 @@ var BSON = (function (exports) {
7036
5727
  }
7037
5728
  return !continuation;
7038
5729
  }
7039
- exports.validateUtf8 = validateUtf8;
7040
- //# sourceMappingURL=validate_utf8.js.map
7041
- });
7042
-
7043
- unwrapExports(validate_utf8);
7044
- validate_utf8.validateUtf8;
7045
-
7046
- var deserializer = createCommonjsModule(function (module, exports) {
7047
- Object.defineProperty(exports, "__esModule", { value: true });
7048
- exports.deserialize = void 0;
7049
-
7050
-
7051
-
7052
-
7053
-
7054
-
7055
-
7056
-
7057
-
7058
-
7059
-
7060
-
7061
-
7062
-
7063
-
7064
5730
 
7065
5731
  // Internal long versions
7066
- var JS_INT_MAX_LONG = long_1.Long.fromNumber(constants.JS_INT_MAX);
7067
- var JS_INT_MIN_LONG = long_1.Long.fromNumber(constants.JS_INT_MIN);
5732
+ var JS_INT_MAX_LONG = Long.fromNumber(JS_INT_MAX);
5733
+ var JS_INT_MIN_LONG = Long.fromNumber(JS_INT_MIN);
7068
5734
  var functionCache = {};
7069
- function deserialize(buffer, options, isArray) {
5735
+ function deserialize$1(buffer, options, isArray) {
7070
5736
  options = options == null ? {} : options;
7071
5737
  var index = options && options.index ? options.index : 0;
7072
5738
  // Read the document size
@@ -7093,8 +5759,8 @@ var BSON = (function (exports) {
7093
5759
  // Start deserializtion
7094
5760
  return deserializeObject(buffer, index, options, isArray);
7095
5761
  }
7096
- exports.deserialize = deserialize;
7097
- function deserializeObject(buffer$1, index, options, isArray) {
5762
+ var allowedDBRefKeys = /^\$ref$|^\$id$|^\$db$/;
5763
+ function deserializeObject(buffer, index, options, isArray) {
7098
5764
  if (isArray === void 0) { isArray = false; }
7099
5765
  var evalFunctions = options['evalFunctions'] == null ? false : options['evalFunctions'];
7100
5766
  var cacheFunctions = options['cacheFunctions'] == null ? false : options['cacheFunctions'];
@@ -7110,115 +5776,124 @@ var BSON = (function (exports) {
7110
5776
  // Set the start index
7111
5777
  var startIndex = index;
7112
5778
  // Validate that we have at least 4 bytes of buffer
7113
- if (buffer$1.length < 5)
5779
+ if (buffer.length < 5)
7114
5780
  throw new Error('corrupt bson message < 5 bytes long');
7115
5781
  // Read the document size
7116
- var size = buffer$1[index++] | (buffer$1[index++] << 8) | (buffer$1[index++] << 16) | (buffer$1[index++] << 24);
5782
+ var size = buffer[index++] | (buffer[index++] << 8) | (buffer[index++] << 16) | (buffer[index++] << 24);
7117
5783
  // Ensure buffer is valid size
7118
- if (size < 5 || size > buffer$1.length)
5784
+ if (size < 5 || size > buffer.length)
7119
5785
  throw new Error('corrupt bson message');
7120
5786
  // Create holding object
7121
5787
  var object = isArray ? [] : {};
7122
5788
  // Used for arrays to skip having to perform utf8 decoding
7123
5789
  var arrayIndex = 0;
7124
5790
  var done = false;
5791
+ var isPossibleDBRef = isArray ? false : null;
7125
5792
  // While we have more left data left keep parsing
7126
5793
  while (!done) {
7127
5794
  // Read the type
7128
- var elementType = buffer$1[index++];
5795
+ var elementType = buffer[index++];
7129
5796
  // If we get a zero it's the last byte, exit
7130
5797
  if (elementType === 0)
7131
5798
  break;
7132
5799
  // Get the start search index
7133
5800
  var i = index;
7134
5801
  // Locate the end of the c string
7135
- while (buffer$1[i] !== 0x00 && i < buffer$1.length) {
5802
+ while (buffer[i] !== 0x00 && i < buffer.length) {
7136
5803
  i++;
7137
5804
  }
7138
5805
  // If are at the end of the buffer there is a problem with the document
7139
- if (i >= buffer$1.byteLength)
5806
+ if (i >= buffer.byteLength)
7140
5807
  throw new Error('Bad BSON Document: illegal CString');
7141
- var name = isArray ? arrayIndex++ : buffer$1.toString('utf8', index, i);
5808
+ var name = isArray ? arrayIndex++ : buffer.toString('utf8', index, i);
5809
+ if (isPossibleDBRef !== false && name[0] === '$') {
5810
+ isPossibleDBRef = allowedDBRefKeys.test(name);
5811
+ }
7142
5812
  var value = void 0;
7143
5813
  index = i + 1;
7144
- if (elementType === constants.BSON_DATA_STRING) {
7145
- var stringSize = buffer$1[index++] |
7146
- (buffer$1[index++] << 8) |
7147
- (buffer$1[index++] << 16) |
7148
- (buffer$1[index++] << 24);
5814
+ if (elementType === BSON_DATA_STRING) {
5815
+ var stringSize = buffer[index++] |
5816
+ (buffer[index++] << 8) |
5817
+ (buffer[index++] << 16) |
5818
+ (buffer[index++] << 24);
7149
5819
  if (stringSize <= 0 ||
7150
- stringSize > buffer$1.length - index ||
7151
- buffer$1[index + stringSize - 1] !== 0)
5820
+ stringSize > buffer.length - index ||
5821
+ buffer[index + stringSize - 1] !== 0)
7152
5822
  throw new Error('bad string length in bson');
7153
- if (!validate_utf8.validateUtf8(buffer$1, index, index + stringSize - 1)) {
7154
- throw new Error('Invalid UTF-8 string in BSON document');
5823
+ value = buffer.toString('utf8', index, index + stringSize - 1);
5824
+ for (var i_1 = 0; i_1 < value.length; i_1++) {
5825
+ if (value.charCodeAt(i_1) === 0xfffd) {
5826
+ if (!validateUtf8(buffer, index, index + stringSize - 1)) {
5827
+ throw new Error('Invalid UTF-8 string in BSON document');
5828
+ }
5829
+ break;
5830
+ }
7155
5831
  }
7156
- value = buffer$1.toString('utf8', index, index + stringSize - 1);
7157
5832
  index = index + stringSize;
7158
5833
  }
7159
- else if (elementType === constants.BSON_DATA_OID) {
7160
- var oid = buffer.Buffer.alloc(12);
7161
- buffer$1.copy(oid, 0, index, index + 12);
7162
- value = new objectid.ObjectId(oid);
5834
+ else if (elementType === BSON_DATA_OID) {
5835
+ var oid = buffer_1.alloc(12);
5836
+ buffer.copy(oid, 0, index, index + 12);
5837
+ value = new ObjectId(oid);
7163
5838
  index = index + 12;
7164
5839
  }
7165
- else if (elementType === constants.BSON_DATA_INT && promoteValues === false) {
7166
- value = new int_32.Int32(buffer$1[index++] | (buffer$1[index++] << 8) | (buffer$1[index++] << 16) | (buffer$1[index++] << 24));
5840
+ else if (elementType === BSON_DATA_INT && promoteValues === false) {
5841
+ value = new Int32(buffer[index++] | (buffer[index++] << 8) | (buffer[index++] << 16) | (buffer[index++] << 24));
7167
5842
  }
7168
- else if (elementType === constants.BSON_DATA_INT) {
5843
+ else if (elementType === BSON_DATA_INT) {
7169
5844
  value =
7170
- buffer$1[index++] |
7171
- (buffer$1[index++] << 8) |
7172
- (buffer$1[index++] << 16) |
7173
- (buffer$1[index++] << 24);
5845
+ buffer[index++] |
5846
+ (buffer[index++] << 8) |
5847
+ (buffer[index++] << 16) |
5848
+ (buffer[index++] << 24);
7174
5849
  }
7175
- else if (elementType === constants.BSON_DATA_NUMBER && promoteValues === false) {
7176
- value = new double_1.Double(buffer$1.readDoubleLE(index));
5850
+ else if (elementType === BSON_DATA_NUMBER && promoteValues === false) {
5851
+ value = new Double(buffer.readDoubleLE(index));
7177
5852
  index = index + 8;
7178
5853
  }
7179
- else if (elementType === constants.BSON_DATA_NUMBER) {
7180
- value = buffer$1.readDoubleLE(index);
5854
+ else if (elementType === BSON_DATA_NUMBER) {
5855
+ value = buffer.readDoubleLE(index);
7181
5856
  index = index + 8;
7182
5857
  }
7183
- else if (elementType === constants.BSON_DATA_DATE) {
7184
- var lowBits = buffer$1[index++] |
7185
- (buffer$1[index++] << 8) |
7186
- (buffer$1[index++] << 16) |
7187
- (buffer$1[index++] << 24);
7188
- var highBits = buffer$1[index++] |
7189
- (buffer$1[index++] << 8) |
7190
- (buffer$1[index++] << 16) |
7191
- (buffer$1[index++] << 24);
7192
- value = new Date(new long_1.Long(lowBits, highBits).toNumber());
7193
- }
7194
- else if (elementType === constants.BSON_DATA_BOOLEAN) {
7195
- if (buffer$1[index] !== 0 && buffer$1[index] !== 1)
5858
+ else if (elementType === BSON_DATA_DATE) {
5859
+ var lowBits = buffer[index++] |
5860
+ (buffer[index++] << 8) |
5861
+ (buffer[index++] << 16) |
5862
+ (buffer[index++] << 24);
5863
+ var highBits = buffer[index++] |
5864
+ (buffer[index++] << 8) |
5865
+ (buffer[index++] << 16) |
5866
+ (buffer[index++] << 24);
5867
+ value = new Date(new Long(lowBits, highBits).toNumber());
5868
+ }
5869
+ else if (elementType === BSON_DATA_BOOLEAN) {
5870
+ if (buffer[index] !== 0 && buffer[index] !== 1)
7196
5871
  throw new Error('illegal boolean type value');
7197
- value = buffer$1[index++] === 1;
5872
+ value = buffer[index++] === 1;
7198
5873
  }
7199
- else if (elementType === constants.BSON_DATA_OBJECT) {
5874
+ else if (elementType === BSON_DATA_OBJECT) {
7200
5875
  var _index = index;
7201
- var objectSize = buffer$1[index] |
7202
- (buffer$1[index + 1] << 8) |
7203
- (buffer$1[index + 2] << 16) |
7204
- (buffer$1[index + 3] << 24);
7205
- if (objectSize <= 0 || objectSize > buffer$1.length - index)
5876
+ var objectSize = buffer[index] |
5877
+ (buffer[index + 1] << 8) |
5878
+ (buffer[index + 2] << 16) |
5879
+ (buffer[index + 3] << 24);
5880
+ if (objectSize <= 0 || objectSize > buffer.length - index)
7206
5881
  throw new Error('bad embedded document length in bson');
7207
5882
  // We have a raw value
7208
5883
  if (raw) {
7209
- value = buffer$1.slice(index, index + objectSize);
5884
+ value = buffer.slice(index, index + objectSize);
7210
5885
  }
7211
5886
  else {
7212
- value = deserializeObject(buffer$1, _index, options, false);
5887
+ value = deserializeObject(buffer, _index, options, false);
7213
5888
  }
7214
5889
  index = index + objectSize;
7215
5890
  }
7216
- else if (elementType === constants.BSON_DATA_ARRAY) {
5891
+ else if (elementType === BSON_DATA_ARRAY) {
7217
5892
  var _index = index;
7218
- var objectSize = buffer$1[index] |
7219
- (buffer$1[index + 1] << 8) |
7220
- (buffer$1[index + 2] << 16) |
7221
- (buffer$1[index + 3] << 24);
5893
+ var objectSize = buffer[index] |
5894
+ (buffer[index + 1] << 8) |
5895
+ (buffer[index + 2] << 16) |
5896
+ (buffer[index + 3] << 24);
7222
5897
  var arrayOptions = options;
7223
5898
  // Stop index
7224
5899
  var stopIndex = index + objectSize;
@@ -7230,30 +5905,30 @@ var BSON = (function (exports) {
7230
5905
  }
7231
5906
  arrayOptions['raw'] = true;
7232
5907
  }
7233
- value = deserializeObject(buffer$1, _index, arrayOptions, true);
5908
+ value = deserializeObject(buffer, _index, arrayOptions, true);
7234
5909
  index = index + objectSize;
7235
- if (buffer$1[index - 1] !== 0)
5910
+ if (buffer[index - 1] !== 0)
7236
5911
  throw new Error('invalid array terminator byte');
7237
5912
  if (index !== stopIndex)
7238
5913
  throw new Error('corrupted array bson');
7239
5914
  }
7240
- else if (elementType === constants.BSON_DATA_UNDEFINED) {
5915
+ else if (elementType === BSON_DATA_UNDEFINED) {
7241
5916
  value = undefined;
7242
5917
  }
7243
- else if (elementType === constants.BSON_DATA_NULL) {
5918
+ else if (elementType === BSON_DATA_NULL) {
7244
5919
  value = null;
7245
5920
  }
7246
- else if (elementType === constants.BSON_DATA_LONG) {
5921
+ else if (elementType === BSON_DATA_LONG) {
7247
5922
  // Unpack the low and high bits
7248
- var lowBits = buffer$1[index++] |
7249
- (buffer$1[index++] << 8) |
7250
- (buffer$1[index++] << 16) |
7251
- (buffer$1[index++] << 24);
7252
- var highBits = buffer$1[index++] |
7253
- (buffer$1[index++] << 8) |
7254
- (buffer$1[index++] << 16) |
7255
- (buffer$1[index++] << 24);
7256
- var long = new long_1.Long(lowBits, highBits);
5923
+ var lowBits = buffer[index++] |
5924
+ (buffer[index++] << 8) |
5925
+ (buffer[index++] << 16) |
5926
+ (buffer[index++] << 24);
5927
+ var highBits = buffer[index++] |
5928
+ (buffer[index++] << 8) |
5929
+ (buffer[index++] << 16) |
5930
+ (buffer[index++] << 24);
5931
+ var long = new Long(lowBits, highBits);
7257
5932
  // Promote the long if possible
7258
5933
  if (promoteLongs && promoteValues === true) {
7259
5934
  value =
@@ -7265,45 +5940,45 @@ var BSON = (function (exports) {
7265
5940
  value = long;
7266
5941
  }
7267
5942
  }
7268
- else if (elementType === constants.BSON_DATA_DECIMAL128) {
5943
+ else if (elementType === BSON_DATA_DECIMAL128) {
7269
5944
  // Buffer to contain the decimal bytes
7270
- var bytes = buffer.Buffer.alloc(16);
5945
+ var bytes = buffer_1.alloc(16);
7271
5946
  // Copy the next 16 bytes into the bytes buffer
7272
- buffer$1.copy(bytes, 0, index, index + 16);
5947
+ buffer.copy(bytes, 0, index, index + 16);
7273
5948
  // Update index
7274
5949
  index = index + 16;
7275
5950
  // Assign the new Decimal128 value
7276
- var decimal128$1 = new decimal128.Decimal128(bytes);
5951
+ var decimal128 = new Decimal128(bytes);
7277
5952
  // If we have an alternative mapper use that
7278
- if ('toObject' in decimal128$1 && typeof decimal128$1.toObject === 'function') {
7279
- value = decimal128$1.toObject();
5953
+ if ('toObject' in decimal128 && typeof decimal128.toObject === 'function') {
5954
+ value = decimal128.toObject();
7280
5955
  }
7281
5956
  else {
7282
- value = decimal128$1;
5957
+ value = decimal128;
7283
5958
  }
7284
5959
  }
7285
- else if (elementType === constants.BSON_DATA_BINARY) {
7286
- var binarySize = buffer$1[index++] |
7287
- (buffer$1[index++] << 8) |
7288
- (buffer$1[index++] << 16) |
7289
- (buffer$1[index++] << 24);
5960
+ else if (elementType === BSON_DATA_BINARY) {
5961
+ var binarySize = buffer[index++] |
5962
+ (buffer[index++] << 8) |
5963
+ (buffer[index++] << 16) |
5964
+ (buffer[index++] << 24);
7290
5965
  var totalBinarySize = binarySize;
7291
- var subType = buffer$1[index++];
5966
+ var subType = buffer[index++];
7292
5967
  // Did we have a negative binary size, throw
7293
5968
  if (binarySize < 0)
7294
5969
  throw new Error('Negative binary type element size found');
7295
5970
  // Is the length longer than the document
7296
- if (binarySize > buffer$1.byteLength)
5971
+ if (binarySize > buffer.byteLength)
7297
5972
  throw new Error('Binary type size larger than document size');
7298
5973
  // Decode as raw Buffer object if options specifies it
7299
- if (buffer$1['slice'] != null) {
5974
+ if (buffer['slice'] != null) {
7300
5975
  // If we have subtype 2 skip the 4 bytes for the size
7301
- if (subType === binary.Binary.SUBTYPE_BYTE_ARRAY) {
5976
+ if (subType === Binary.SUBTYPE_BYTE_ARRAY) {
7302
5977
  binarySize =
7303
- buffer$1[index++] |
7304
- (buffer$1[index++] << 8) |
7305
- (buffer$1[index++] << 16) |
7306
- (buffer$1[index++] << 24);
5978
+ buffer[index++] |
5979
+ (buffer[index++] << 8) |
5980
+ (buffer[index++] << 16) |
5981
+ (buffer[index++] << 24);
7307
5982
  if (binarySize < 0)
7308
5983
  throw new Error('Negative binary type element size found for subtype 0x02');
7309
5984
  if (binarySize > totalBinarySize - 4)
@@ -7312,21 +5987,21 @@ var BSON = (function (exports) {
7312
5987
  throw new Error('Binary type with subtype 0x02 contains too short binary size');
7313
5988
  }
7314
5989
  if (promoteBuffers && promoteValues) {
7315
- value = buffer$1.slice(index, index + binarySize);
5990
+ value = buffer.slice(index, index + binarySize);
7316
5991
  }
7317
5992
  else {
7318
- value = new binary.Binary(buffer$1.slice(index, index + binarySize), subType);
5993
+ value = new Binary(buffer.slice(index, index + binarySize), subType);
7319
5994
  }
7320
5995
  }
7321
5996
  else {
7322
- var _buffer = buffer.Buffer.alloc(binarySize);
5997
+ var _buffer = buffer_1.alloc(binarySize);
7323
5998
  // If we have subtype 2 skip the 4 bytes for the size
7324
- if (subType === binary.Binary.SUBTYPE_BYTE_ARRAY) {
5999
+ if (subType === Binary.SUBTYPE_BYTE_ARRAY) {
7325
6000
  binarySize =
7326
- buffer$1[index++] |
7327
- (buffer$1[index++] << 8) |
7328
- (buffer$1[index++] << 16) |
7329
- (buffer$1[index++] << 24);
6001
+ buffer[index++] |
6002
+ (buffer[index++] << 8) |
6003
+ (buffer[index++] << 16) |
6004
+ (buffer[index++] << 24);
7330
6005
  if (binarySize < 0)
7331
6006
  throw new Error('Negative binary type element size found for subtype 0x02');
7332
6007
  if (binarySize > totalBinarySize - 4)
@@ -7336,43 +6011,43 @@ var BSON = (function (exports) {
7336
6011
  }
7337
6012
  // Copy the data
7338
6013
  for (i = 0; i < binarySize; i++) {
7339
- _buffer[i] = buffer$1[index + i];
6014
+ _buffer[i] = buffer[index + i];
7340
6015
  }
7341
6016
  if (promoteBuffers && promoteValues) {
7342
6017
  value = _buffer;
7343
6018
  }
7344
6019
  else {
7345
- value = new binary.Binary(_buffer, subType);
6020
+ value = new Binary(_buffer, subType);
7346
6021
  }
7347
6022
  }
7348
6023
  // Update the index
7349
6024
  index = index + binarySize;
7350
6025
  }
7351
- else if (elementType === constants.BSON_DATA_REGEXP && bsonRegExp === false) {
6026
+ else if (elementType === BSON_DATA_REGEXP && bsonRegExp === false) {
7352
6027
  // Get the start search index
7353
6028
  i = index;
7354
6029
  // Locate the end of the c string
7355
- while (buffer$1[i] !== 0x00 && i < buffer$1.length) {
6030
+ while (buffer[i] !== 0x00 && i < buffer.length) {
7356
6031
  i++;
7357
6032
  }
7358
6033
  // If are at the end of the buffer there is a problem with the document
7359
- if (i >= buffer$1.length)
6034
+ if (i >= buffer.length)
7360
6035
  throw new Error('Bad BSON Document: illegal CString');
7361
6036
  // Return the C string
7362
- var source = buffer$1.toString('utf8', index, i);
6037
+ var source = buffer.toString('utf8', index, i);
7363
6038
  // Create the regexp
7364
6039
  index = i + 1;
7365
6040
  // Get the start search index
7366
6041
  i = index;
7367
6042
  // Locate the end of the c string
7368
- while (buffer$1[i] !== 0x00 && i < buffer$1.length) {
6043
+ while (buffer[i] !== 0x00 && i < buffer.length) {
7369
6044
  i++;
7370
6045
  }
7371
6046
  // If are at the end of the buffer there is a problem with the document
7372
- if (i >= buffer$1.length)
6047
+ if (i >= buffer.length)
7373
6048
  throw new Error('Bad BSON Document: illegal CString');
7374
6049
  // Return the C string
7375
- var regExpOptions = buffer$1.toString('utf8', index, i);
6050
+ var regExpOptions = buffer.toString('utf8', index, i);
7376
6051
  index = i + 1;
7377
6052
  // For each option add the corresponding one for javascript
7378
6053
  var optionsArray = new Array(regExpOptions.length);
@@ -7392,74 +6067,74 @@ var BSON = (function (exports) {
7392
6067
  }
7393
6068
  value = new RegExp(source, optionsArray.join(''));
7394
6069
  }
7395
- else if (elementType === constants.BSON_DATA_REGEXP && bsonRegExp === true) {
6070
+ else if (elementType === BSON_DATA_REGEXP && bsonRegExp === true) {
7396
6071
  // Get the start search index
7397
6072
  i = index;
7398
6073
  // Locate the end of the c string
7399
- while (buffer$1[i] !== 0x00 && i < buffer$1.length) {
6074
+ while (buffer[i] !== 0x00 && i < buffer.length) {
7400
6075
  i++;
7401
6076
  }
7402
6077
  // If are at the end of the buffer there is a problem with the document
7403
- if (i >= buffer$1.length)
6078
+ if (i >= buffer.length)
7404
6079
  throw new Error('Bad BSON Document: illegal CString');
7405
6080
  // Return the C string
7406
- var source = buffer$1.toString('utf8', index, i);
6081
+ var source = buffer.toString('utf8', index, i);
7407
6082
  index = i + 1;
7408
6083
  // Get the start search index
7409
6084
  i = index;
7410
6085
  // Locate the end of the c string
7411
- while (buffer$1[i] !== 0x00 && i < buffer$1.length) {
6086
+ while (buffer[i] !== 0x00 && i < buffer.length) {
7412
6087
  i++;
7413
6088
  }
7414
6089
  // If are at the end of the buffer there is a problem with the document
7415
- if (i >= buffer$1.length)
6090
+ if (i >= buffer.length)
7416
6091
  throw new Error('Bad BSON Document: illegal CString');
7417
6092
  // Return the C string
7418
- var regExpOptions = buffer$1.toString('utf8', index, i);
6093
+ var regExpOptions = buffer.toString('utf8', index, i);
7419
6094
  index = i + 1;
7420
6095
  // Set the object
7421
- value = new regexp.BSONRegExp(source, regExpOptions);
6096
+ value = new BSONRegExp(source, regExpOptions);
7422
6097
  }
7423
- else if (elementType === constants.BSON_DATA_SYMBOL) {
7424
- var stringSize = buffer$1[index++] |
7425
- (buffer$1[index++] << 8) |
7426
- (buffer$1[index++] << 16) |
7427
- (buffer$1[index++] << 24);
6098
+ else if (elementType === BSON_DATA_SYMBOL) {
6099
+ var stringSize = buffer[index++] |
6100
+ (buffer[index++] << 8) |
6101
+ (buffer[index++] << 16) |
6102
+ (buffer[index++] << 24);
7428
6103
  if (stringSize <= 0 ||
7429
- stringSize > buffer$1.length - index ||
7430
- buffer$1[index + stringSize - 1] !== 0)
6104
+ stringSize > buffer.length - index ||
6105
+ buffer[index + stringSize - 1] !== 0)
7431
6106
  throw new Error('bad string length in bson');
7432
- var symbol$1 = buffer$1.toString('utf8', index, index + stringSize - 1);
7433
- value = promoteValues ? symbol$1 : new symbol.BSONSymbol(symbol$1);
6107
+ var symbol = buffer.toString('utf8', index, index + stringSize - 1);
6108
+ value = promoteValues ? symbol : new BSONSymbol(symbol);
7434
6109
  index = index + stringSize;
7435
6110
  }
7436
- else if (elementType === constants.BSON_DATA_TIMESTAMP) {
7437
- var lowBits = buffer$1[index++] |
7438
- (buffer$1[index++] << 8) |
7439
- (buffer$1[index++] << 16) |
7440
- (buffer$1[index++] << 24);
7441
- var highBits = buffer$1[index++] |
7442
- (buffer$1[index++] << 8) |
7443
- (buffer$1[index++] << 16) |
7444
- (buffer$1[index++] << 24);
7445
- value = new timestamp.Timestamp(lowBits, highBits);
7446
- }
7447
- else if (elementType === constants.BSON_DATA_MIN_KEY) {
7448
- value = new min_key.MinKey();
7449
- }
7450
- else if (elementType === constants.BSON_DATA_MAX_KEY) {
7451
- value = new max_key.MaxKey();
7452
- }
7453
- else if (elementType === constants.BSON_DATA_CODE) {
7454
- var stringSize = buffer$1[index++] |
7455
- (buffer$1[index++] << 8) |
7456
- (buffer$1[index++] << 16) |
7457
- (buffer$1[index++] << 24);
6111
+ else if (elementType === BSON_DATA_TIMESTAMP) {
6112
+ var lowBits = buffer[index++] |
6113
+ (buffer[index++] << 8) |
6114
+ (buffer[index++] << 16) |
6115
+ (buffer[index++] << 24);
6116
+ var highBits = buffer[index++] |
6117
+ (buffer[index++] << 8) |
6118
+ (buffer[index++] << 16) |
6119
+ (buffer[index++] << 24);
6120
+ value = new Timestamp(lowBits, highBits);
6121
+ }
6122
+ else if (elementType === BSON_DATA_MIN_KEY) {
6123
+ value = new MinKey();
6124
+ }
6125
+ else if (elementType === BSON_DATA_MAX_KEY) {
6126
+ value = new MaxKey();
6127
+ }
6128
+ else if (elementType === BSON_DATA_CODE) {
6129
+ var stringSize = buffer[index++] |
6130
+ (buffer[index++] << 8) |
6131
+ (buffer[index++] << 16) |
6132
+ (buffer[index++] << 24);
7458
6133
  if (stringSize <= 0 ||
7459
- stringSize > buffer$1.length - index ||
7460
- buffer$1[index + stringSize - 1] !== 0)
6134
+ stringSize > buffer.length - index ||
6135
+ buffer[index + stringSize - 1] !== 0)
7461
6136
  throw new Error('bad string length in bson');
7462
- var functionString = buffer$1.toString('utf8', index, index + stringSize - 1);
6137
+ var functionString = buffer.toString('utf8', index, index + stringSize - 1);
7463
6138
  // If we are evaluating the functions
7464
6139
  if (evalFunctions) {
7465
6140
  // If we have cache enabled let's look for the md5 of the function in the cache
@@ -7472,43 +6147,43 @@ var BSON = (function (exports) {
7472
6147
  }
7473
6148
  }
7474
6149
  else {
7475
- value = new code.Code(functionString);
6150
+ value = new Code(functionString);
7476
6151
  }
7477
6152
  // Update parse index position
7478
6153
  index = index + stringSize;
7479
6154
  }
7480
- else if (elementType === constants.BSON_DATA_CODE_W_SCOPE) {
7481
- var totalSize = buffer$1[index++] |
7482
- (buffer$1[index++] << 8) |
7483
- (buffer$1[index++] << 16) |
7484
- (buffer$1[index++] << 24);
6155
+ else if (elementType === BSON_DATA_CODE_W_SCOPE) {
6156
+ var totalSize = buffer[index++] |
6157
+ (buffer[index++] << 8) |
6158
+ (buffer[index++] << 16) |
6159
+ (buffer[index++] << 24);
7485
6160
  // Element cannot be shorter than totalSize + stringSize + documentSize + terminator
7486
6161
  if (totalSize < 4 + 4 + 4 + 1) {
7487
6162
  throw new Error('code_w_scope total size shorter minimum expected length');
7488
6163
  }
7489
6164
  // Get the code string size
7490
- var stringSize = buffer$1[index++] |
7491
- (buffer$1[index++] << 8) |
7492
- (buffer$1[index++] << 16) |
7493
- (buffer$1[index++] << 24);
6165
+ var stringSize = buffer[index++] |
6166
+ (buffer[index++] << 8) |
6167
+ (buffer[index++] << 16) |
6168
+ (buffer[index++] << 24);
7494
6169
  // Check if we have a valid string
7495
6170
  if (stringSize <= 0 ||
7496
- stringSize > buffer$1.length - index ||
7497
- buffer$1[index + stringSize - 1] !== 0)
6171
+ stringSize > buffer.length - index ||
6172
+ buffer[index + stringSize - 1] !== 0)
7498
6173
  throw new Error('bad string length in bson');
7499
6174
  // Javascript function
7500
- var functionString = buffer$1.toString('utf8', index, index + stringSize - 1);
6175
+ var functionString = buffer.toString('utf8', index, index + stringSize - 1);
7501
6176
  // Update parse index position
7502
6177
  index = index + stringSize;
7503
6178
  // Parse the element
7504
6179
  var _index = index;
7505
6180
  // Decode the size of the object document
7506
- var objectSize = buffer$1[index] |
7507
- (buffer$1[index + 1] << 8) |
7508
- (buffer$1[index + 2] << 16) |
7509
- (buffer$1[index + 3] << 24);
6181
+ var objectSize = buffer[index] |
6182
+ (buffer[index + 1] << 8) |
6183
+ (buffer[index + 2] << 16) |
6184
+ (buffer[index + 3] << 24);
7510
6185
  // Decode the scope object
7511
- var scopeObject = deserializeObject(buffer$1, _index, options, false);
6186
+ var scopeObject = deserializeObject(buffer, _index, options, false);
7512
6187
  // Adjust the index
7513
6188
  index = index + objectSize;
7514
6189
  // Check if field length is too short
@@ -7532,35 +6207,35 @@ var BSON = (function (exports) {
7532
6207
  value.scope = scopeObject;
7533
6208
  }
7534
6209
  else {
7535
- value = new code.Code(functionString, scopeObject);
6210
+ value = new Code(functionString, scopeObject);
7536
6211
  }
7537
6212
  }
7538
- else if (elementType === constants.BSON_DATA_DBPOINTER) {
6213
+ else if (elementType === BSON_DATA_DBPOINTER) {
7539
6214
  // Get the code string size
7540
- var stringSize = buffer$1[index++] |
7541
- (buffer$1[index++] << 8) |
7542
- (buffer$1[index++] << 16) |
7543
- (buffer$1[index++] << 24);
6215
+ var stringSize = buffer[index++] |
6216
+ (buffer[index++] << 8) |
6217
+ (buffer[index++] << 16) |
6218
+ (buffer[index++] << 24);
7544
6219
  // Check if we have a valid string
7545
6220
  if (stringSize <= 0 ||
7546
- stringSize > buffer$1.length - index ||
7547
- buffer$1[index + stringSize - 1] !== 0)
6221
+ stringSize > buffer.length - index ||
6222
+ buffer[index + stringSize - 1] !== 0)
7548
6223
  throw new Error('bad string length in bson');
7549
6224
  // Namespace
7550
- if (!validate_utf8.validateUtf8(buffer$1, index, index + stringSize - 1)) {
6225
+ if (!validateUtf8(buffer, index, index + stringSize - 1)) {
7551
6226
  throw new Error('Invalid UTF-8 string in BSON document');
7552
6227
  }
7553
- var namespace = buffer$1.toString('utf8', index, index + stringSize - 1);
6228
+ var namespace = buffer.toString('utf8', index, index + stringSize - 1);
7554
6229
  // Update parse index position
7555
6230
  index = index + stringSize;
7556
6231
  // Read the oid
7557
- var oidBuffer = buffer.Buffer.alloc(12);
7558
- buffer$1.copy(oidBuffer, 0, index, index + 12);
7559
- var oid = new objectid.ObjectId(oidBuffer);
6232
+ var oidBuffer = buffer_1.alloc(12);
6233
+ buffer.copy(oidBuffer, 0, index, index + 12);
6234
+ var oid = new ObjectId(oidBuffer);
7560
6235
  // Update the index
7561
6236
  index = index + 12;
7562
6237
  // Upgrade to DBRef type
7563
- value = new db_ref.DBRef(namespace, oid);
6238
+ value = new DBRef(namespace, oid);
7564
6239
  }
7565
6240
  else {
7566
6241
  throw new Error('Detected unknown BSON type ' + elementType.toString(16) + ' for fieldname "' + name + '"');
@@ -7583,22 +6258,15 @@ var BSON = (function (exports) {
7583
6258
  throw new Error('corrupt array bson');
7584
6259
  throw new Error('corrupt object bson');
7585
6260
  }
7586
- // check if object's $ keys are those of a DBRef
7587
- var dollarKeys = Object.keys(object).filter(function (k) { return k.startsWith('$'); });
7588
- var valid = true;
7589
- dollarKeys.forEach(function (k) {
7590
- if (['$ref', '$id', '$db'].indexOf(k) === -1)
7591
- valid = false;
7592
- });
7593
- // if a $key not in "$ref", "$id", "$db", don't make a DBRef
7594
- if (!valid)
6261
+ // if we did not find "$ref", "$id", "$db", or found an extraneous $key, don't make a DBRef
6262
+ if (!isPossibleDBRef)
7595
6263
  return object;
7596
- if (db_ref.isDBRefLike(object)) {
6264
+ if (isDBRefLike(object)) {
7597
6265
  var copy = Object.assign({}, object);
7598
6266
  delete copy.$ref;
7599
6267
  delete copy.$id;
7600
6268
  delete copy.$db;
7601
- return new db_ref.DBRef(object.$ref, object.$id, object.$db, copy);
6269
+ return new DBRef(object.$ref, object.$id, object.$db, copy);
7602
6270
  }
7603
6271
  return object;
7604
6272
  }
@@ -7617,81 +6285,8 @@ var BSON = (function (exports) {
7617
6285
  // Set the object
7618
6286
  return functionCache[functionString].bind(object);
7619
6287
  }
7620
- //# sourceMappingURL=deserializer.js.map
7621
- });
7622
-
7623
- unwrapExports(deserializer);
7624
- deserializer.deserialize;
7625
6288
 
7626
- var float_parser = createCommonjsModule(function (module, exports) {
7627
6289
  // Copyright (c) 2008, Fair Oaks Labs, Inc.
7628
- // All rights reserved.
7629
- //
7630
- // Redistribution and use in source and binary forms, with or without
7631
- // modification, are permitted provided that the following conditions are met:
7632
- //
7633
- // * Redistributions of source code must retain the above copyright notice,
7634
- // this list of conditions and the following disclaimer.
7635
- //
7636
- // * Redistributions in binary form must reproduce the above copyright notice,
7637
- // this list of conditions and the following disclaimer in the documentation
7638
- // and/or other materials provided with the distribution.
7639
- //
7640
- // * Neither the name of Fair Oaks Labs, Inc. nor the names of its contributors
7641
- // may be used to endorse or promote products derived from this software
7642
- // without specific prior written permission.
7643
- //
7644
- // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
7645
- // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
7646
- // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
7647
- // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
7648
- // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
7649
- // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
7650
- // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
7651
- // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
7652
- // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
7653
- // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
7654
- // POSSIBILITY OF SUCH DAMAGE.
7655
- //
7656
- //
7657
- // Modifications to writeIEEE754 to support negative zeroes made by Brian White
7658
- Object.defineProperty(exports, "__esModule", { value: true });
7659
- exports.writeIEEE754 = exports.readIEEE754 = void 0;
7660
- function readIEEE754(buffer, offset, endian, mLen, nBytes) {
7661
- var e;
7662
- var m;
7663
- var bBE = endian === 'big';
7664
- var eLen = nBytes * 8 - mLen - 1;
7665
- var eMax = (1 << eLen) - 1;
7666
- var eBias = eMax >> 1;
7667
- var nBits = -7;
7668
- var i = bBE ? 0 : nBytes - 1;
7669
- var d = bBE ? 1 : -1;
7670
- var s = buffer[offset + i];
7671
- i += d;
7672
- e = s & ((1 << -nBits) - 1);
7673
- s >>= -nBits;
7674
- nBits += eLen;
7675
- for (; nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8)
7676
- ;
7677
- m = e & ((1 << -nBits) - 1);
7678
- e >>= -nBits;
7679
- nBits += mLen;
7680
- for (; nBits > 0; m = m * 256 + buffer[offset + i], i += d, nBits -= 8)
7681
- ;
7682
- if (e === 0) {
7683
- e = 1 - eBias;
7684
- }
7685
- else if (e === eMax) {
7686
- return m ? NaN : (s ? -1 : 1) * Infinity;
7687
- }
7688
- else {
7689
- m = m + Math.pow(2, mLen);
7690
- e = e - eBias;
7691
- }
7692
- return (s ? -1 : 1) * m * Math.pow(2, e - mLen);
7693
- }
7694
- exports.readIEEE754 = readIEEE754;
7695
6290
  function writeIEEE754(buffer, value, offset, endian, mLen, nBytes) {
7696
6291
  var e;
7697
6292
  var m;
@@ -7758,24 +6353,6 @@ var BSON = (function (exports) {
7758
6353
  }
7759
6354
  buffer[offset + i - d] |= s * 128;
7760
6355
  }
7761
- exports.writeIEEE754 = writeIEEE754;
7762
- //# sourceMappingURL=float_parser.js.map
7763
- });
7764
-
7765
- unwrapExports(float_parser);
7766
- float_parser.writeIEEE754;
7767
- float_parser.readIEEE754;
7768
-
7769
- var serializer = createCommonjsModule(function (module, exports) {
7770
- Object.defineProperty(exports, "__esModule", { value: true });
7771
- exports.serializeInto = void 0;
7772
-
7773
-
7774
-
7775
-
7776
-
7777
-
7778
-
7779
6356
 
7780
6357
  var regexp = /\x00/; // eslint-disable-line no-control-regex
7781
6358
  var ignoreKeys = new Set(['$db', '$ref', '$id', '$clusterTime']);
@@ -7786,7 +6363,7 @@ var BSON = (function (exports) {
7786
6363
  */
7787
6364
  function serializeString(buffer, key, value, index, isArray) {
7788
6365
  // Encode String type
7789
- buffer[index++] = constants.BSON_DATA_STRING;
6366
+ buffer[index++] = BSON_DATA_STRING;
7790
6367
  // Number of written bytes
7791
6368
  var numberOfWrittenBytes = !isArray
7792
6369
  ? buffer.write(key, index, undefined, 'utf8')
@@ -7811,11 +6388,11 @@ var BSON = (function (exports) {
7811
6388
  // We have an integer value
7812
6389
  // TODO(NODE-2529): Add support for big int
7813
6390
  if (Number.isInteger(value) &&
7814
- value >= constants.BSON_INT32_MIN &&
7815
- value <= constants.BSON_INT32_MAX) {
6391
+ value >= BSON_INT32_MIN &&
6392
+ value <= BSON_INT32_MAX) {
7816
6393
  // If the value fits in 32 bits encode as int32
7817
6394
  // Set int type 32 bits or less
7818
- buffer[index++] = constants.BSON_DATA_INT;
6395
+ buffer[index++] = BSON_DATA_INT;
7819
6396
  // Number of written bytes
7820
6397
  var numberOfWrittenBytes = !isArray
7821
6398
  ? buffer.write(key, index, undefined, 'utf8')
@@ -7831,7 +6408,7 @@ var BSON = (function (exports) {
7831
6408
  }
7832
6409
  else {
7833
6410
  // Encode as double
7834
- buffer[index++] = constants.BSON_DATA_NUMBER;
6411
+ buffer[index++] = BSON_DATA_NUMBER;
7835
6412
  // Number of written bytes
7836
6413
  var numberOfWrittenBytes = !isArray
7837
6414
  ? buffer.write(key, index, undefined, 'utf8')
@@ -7840,7 +6417,7 @@ var BSON = (function (exports) {
7840
6417
  index = index + numberOfWrittenBytes;
7841
6418
  buffer[index++] = 0;
7842
6419
  // Write float
7843
- float_parser.writeIEEE754(buffer, value, index, 'little', 52, 8);
6420
+ writeIEEE754(buffer, value, index, 'little', 52, 8);
7844
6421
  // Adjust index
7845
6422
  index = index + 8;
7846
6423
  }
@@ -7848,7 +6425,7 @@ var BSON = (function (exports) {
7848
6425
  }
7849
6426
  function serializeNull(buffer, key, _, index, isArray) {
7850
6427
  // Set long type
7851
- buffer[index++] = constants.BSON_DATA_NULL;
6428
+ buffer[index++] = BSON_DATA_NULL;
7852
6429
  // Number of written bytes
7853
6430
  var numberOfWrittenBytes = !isArray
7854
6431
  ? buffer.write(key, index, undefined, 'utf8')
@@ -7860,7 +6437,7 @@ var BSON = (function (exports) {
7860
6437
  }
7861
6438
  function serializeBoolean(buffer, key, value, index, isArray) {
7862
6439
  // Write the type
7863
- buffer[index++] = constants.BSON_DATA_BOOLEAN;
6440
+ buffer[index++] = BSON_DATA_BOOLEAN;
7864
6441
  // Number of written bytes
7865
6442
  var numberOfWrittenBytes = !isArray
7866
6443
  ? buffer.write(key, index, undefined, 'utf8')
@@ -7874,7 +6451,7 @@ var BSON = (function (exports) {
7874
6451
  }
7875
6452
  function serializeDate(buffer, key, value, index, isArray) {
7876
6453
  // Write the type
7877
- buffer[index++] = constants.BSON_DATA_DATE;
6454
+ buffer[index++] = BSON_DATA_DATE;
7878
6455
  // Number of written bytes
7879
6456
  var numberOfWrittenBytes = !isArray
7880
6457
  ? buffer.write(key, index, undefined, 'utf8')
@@ -7883,7 +6460,7 @@ var BSON = (function (exports) {
7883
6460
  index = index + numberOfWrittenBytes;
7884
6461
  buffer[index++] = 0;
7885
6462
  // Write the date
7886
- var dateInMilis = long_1.Long.fromNumber(value.getTime());
6463
+ var dateInMilis = Long.fromNumber(value.getTime());
7887
6464
  var lowBits = dateInMilis.getLowBits();
7888
6465
  var highBits = dateInMilis.getHighBits();
7889
6466
  // Encode low bits
@@ -7900,7 +6477,7 @@ var BSON = (function (exports) {
7900
6477
  }
7901
6478
  function serializeRegExp(buffer, key, value, index, isArray) {
7902
6479
  // Write the type
7903
- buffer[index++] = constants.BSON_DATA_REGEXP;
6480
+ buffer[index++] = BSON_DATA_REGEXP;
7904
6481
  // Number of written bytes
7905
6482
  var numberOfWrittenBytes = !isArray
7906
6483
  ? buffer.write(key, index, undefined, 'utf8')
@@ -7928,7 +6505,7 @@ var BSON = (function (exports) {
7928
6505
  }
7929
6506
  function serializeBSONRegExp(buffer, key, value, index, isArray) {
7930
6507
  // Write the type
7931
- buffer[index++] = constants.BSON_DATA_REGEXP;
6508
+ buffer[index++] = BSON_DATA_REGEXP;
7932
6509
  // Number of written bytes
7933
6510
  var numberOfWrittenBytes = !isArray
7934
6511
  ? buffer.write(key, index, undefined, 'utf8')
@@ -7955,13 +6532,13 @@ var BSON = (function (exports) {
7955
6532
  function serializeMinMax(buffer, key, value, index, isArray) {
7956
6533
  // Write the type of either min or max key
7957
6534
  if (value === null) {
7958
- buffer[index++] = constants.BSON_DATA_NULL;
6535
+ buffer[index++] = BSON_DATA_NULL;
7959
6536
  }
7960
6537
  else if (value._bsontype === 'MinKey') {
7961
- buffer[index++] = constants.BSON_DATA_MIN_KEY;
6538
+ buffer[index++] = BSON_DATA_MIN_KEY;
7962
6539
  }
7963
6540
  else {
7964
- buffer[index++] = constants.BSON_DATA_MAX_KEY;
6541
+ buffer[index++] = BSON_DATA_MAX_KEY;
7965
6542
  }
7966
6543
  // Number of written bytes
7967
6544
  var numberOfWrittenBytes = !isArray
@@ -7974,7 +6551,7 @@ var BSON = (function (exports) {
7974
6551
  }
7975
6552
  function serializeObjectId(buffer, key, value, index, isArray) {
7976
6553
  // Write the type
7977
- buffer[index++] = constants.BSON_DATA_OID;
6554
+ buffer[index++] = BSON_DATA_OID;
7978
6555
  // Number of written bytes
7979
6556
  var numberOfWrittenBytes = !isArray
7980
6557
  ? buffer.write(key, index, undefined, 'utf8')
@@ -7986,8 +6563,10 @@ var BSON = (function (exports) {
7986
6563
  if (typeof value.id === 'string') {
7987
6564
  buffer.write(value.id, index, undefined, 'binary');
7988
6565
  }
7989
- else if (value.id && value.id.copy) {
7990
- value.id.copy(buffer, index, 0, 12);
6566
+ else if (isUint8Array(value.id)) {
6567
+ // Use the standard JS methods here because buffer.copy() is buggy with the
6568
+ // browser polyfill
6569
+ buffer.set(value.id.subarray(0, 12), index);
7991
6570
  }
7992
6571
  else {
7993
6572
  throw new TypeError('object [' + JSON.stringify(value) + '] is not a valid ObjectId');
@@ -7997,7 +6576,7 @@ var BSON = (function (exports) {
7997
6576
  }
7998
6577
  function serializeBuffer(buffer, key, value, index, isArray) {
7999
6578
  // Write the type
8000
- buffer[index++] = constants.BSON_DATA_BINARY;
6579
+ buffer[index++] = BSON_DATA_BINARY;
8001
6580
  // Number of written bytes
8002
6581
  var numberOfWrittenBytes = !isArray
8003
6582
  ? buffer.write(key, index, undefined, 'utf8')
@@ -8013,9 +6592,9 @@ var BSON = (function (exports) {
8013
6592
  buffer[index++] = (size >> 16) & 0xff;
8014
6593
  buffer[index++] = (size >> 24) & 0xff;
8015
6594
  // Write the default subtype
8016
- buffer[index++] = constants.BSON_BINARY_SUBTYPE_DEFAULT;
6595
+ buffer[index++] = BSON_BINARY_SUBTYPE_DEFAULT;
8017
6596
  // Copy the content form the binary field to the buffer
8018
- buffer.set(ensure_buffer.ensureBuffer(value), index);
6597
+ buffer.set(ensureBuffer(value), index);
8019
6598
  // Adjust the index
8020
6599
  index = index + size;
8021
6600
  return index;
@@ -8034,7 +6613,7 @@ var BSON = (function (exports) {
8034
6613
  // Push value to stack
8035
6614
  path.push(value);
8036
6615
  // Write the type
8037
- buffer[index++] = Array.isArray(value) ? constants.BSON_DATA_ARRAY : constants.BSON_DATA_OBJECT;
6616
+ buffer[index++] = Array.isArray(value) ? BSON_DATA_ARRAY : BSON_DATA_OBJECT;
8038
6617
  // Number of written bytes
8039
6618
  var numberOfWrittenBytes = !isArray
8040
6619
  ? buffer.write(key, index, undefined, 'utf8')
@@ -8048,7 +6627,7 @@ var BSON = (function (exports) {
8048
6627
  return endIndex;
8049
6628
  }
8050
6629
  function serializeDecimal128(buffer, key, value, index, isArray) {
8051
- buffer[index++] = constants.BSON_DATA_DECIMAL128;
6630
+ buffer[index++] = BSON_DATA_DECIMAL128;
8052
6631
  // Number of written bytes
8053
6632
  var numberOfWrittenBytes = !isArray
8054
6633
  ? buffer.write(key, index, undefined, 'utf8')
@@ -8057,13 +6636,15 @@ var BSON = (function (exports) {
8057
6636
  index = index + numberOfWrittenBytes;
8058
6637
  buffer[index++] = 0;
8059
6638
  // Write the data from the value
8060
- value.bytes.copy(buffer, index, 0, 16);
6639
+ // Prefer the standard JS methods because their typechecking is not buggy,
6640
+ // unlike the `buffer` polyfill's.
6641
+ buffer.set(value.bytes.subarray(0, 16), index);
8061
6642
  return index + 16;
8062
6643
  }
8063
6644
  function serializeLong(buffer, key, value, index, isArray) {
8064
6645
  // Write the type
8065
6646
  buffer[index++] =
8066
- value._bsontype === 'Long' ? constants.BSON_DATA_LONG : constants.BSON_DATA_TIMESTAMP;
6647
+ value._bsontype === 'Long' ? BSON_DATA_LONG : BSON_DATA_TIMESTAMP;
8067
6648
  // Number of written bytes
8068
6649
  var numberOfWrittenBytes = !isArray
8069
6650
  ? buffer.write(key, index, undefined, 'utf8')
@@ -8089,7 +6670,7 @@ var BSON = (function (exports) {
8089
6670
  function serializeInt32(buffer, key, value, index, isArray) {
8090
6671
  value = value.valueOf();
8091
6672
  // Set int type 32 bits or less
8092
- buffer[index++] = constants.BSON_DATA_INT;
6673
+ buffer[index++] = BSON_DATA_INT;
8093
6674
  // Number of written bytes
8094
6675
  var numberOfWrittenBytes = !isArray
8095
6676
  ? buffer.write(key, index, undefined, 'utf8')
@@ -8106,7 +6687,7 @@ var BSON = (function (exports) {
8106
6687
  }
8107
6688
  function serializeDouble(buffer, key, value, index, isArray) {
8108
6689
  // Encode as double
8109
- buffer[index++] = constants.BSON_DATA_NUMBER;
6690
+ buffer[index++] = BSON_DATA_NUMBER;
8110
6691
  // Number of written bytes
8111
6692
  var numberOfWrittenBytes = !isArray
8112
6693
  ? buffer.write(key, index, undefined, 'utf8')
@@ -8115,13 +6696,13 @@ var BSON = (function (exports) {
8115
6696
  index = index + numberOfWrittenBytes;
8116
6697
  buffer[index++] = 0;
8117
6698
  // Write float
8118
- float_parser.writeIEEE754(buffer, value.value, index, 'little', 52, 8);
6699
+ writeIEEE754(buffer, value.value, index, 'little', 52, 8);
8119
6700
  // Adjust index
8120
6701
  index = index + 8;
8121
6702
  return index;
8122
6703
  }
8123
6704
  function serializeFunction(buffer, key, value, index, _checkKeys, _depth, isArray) {
8124
- buffer[index++] = constants.BSON_DATA_CODE;
6705
+ buffer[index++] = BSON_DATA_CODE;
8125
6706
  // Number of written bytes
8126
6707
  var numberOfWrittenBytes = !isArray
8127
6708
  ? buffer.write(key, index, undefined, 'utf8')
@@ -8130,7 +6711,7 @@ var BSON = (function (exports) {
8130
6711
  index = index + numberOfWrittenBytes;
8131
6712
  buffer[index++] = 0;
8132
6713
  // Function string
8133
- var functionString = utils.normalizedFunctionString(value);
6714
+ var functionString = normalizedFunctionString(value);
8134
6715
  // Write the string
8135
6716
  var size = buffer.write(functionString, index + 4, undefined, 'utf8') + 1;
8136
6717
  // Write the size of the string to buffer
@@ -8152,7 +6733,7 @@ var BSON = (function (exports) {
8152
6733
  if (isArray === void 0) { isArray = false; }
8153
6734
  if (value.scope && typeof value.scope === 'object') {
8154
6735
  // Write the type
8155
- buffer[index++] = constants.BSON_DATA_CODE_W_SCOPE;
6736
+ buffer[index++] = BSON_DATA_CODE_W_SCOPE;
8156
6737
  // Number of written bytes
8157
6738
  var numberOfWrittenBytes = !isArray
8158
6739
  ? buffer.write(key, index, undefined, 'utf8')
@@ -8193,7 +6774,7 @@ var BSON = (function (exports) {
8193
6774
  buffer[index++] = 0;
8194
6775
  }
8195
6776
  else {
8196
- buffer[index++] = constants.BSON_DATA_CODE;
6777
+ buffer[index++] = BSON_DATA_CODE;
8197
6778
  // Number of written bytes
8198
6779
  var numberOfWrittenBytes = !isArray
8199
6780
  ? buffer.write(key, index, undefined, 'utf8')
@@ -8219,7 +6800,7 @@ var BSON = (function (exports) {
8219
6800
  }
8220
6801
  function serializeBinary(buffer, key, value, index, isArray) {
8221
6802
  // Write the type
8222
- buffer[index++] = constants.BSON_DATA_BINARY;
6803
+ buffer[index++] = BSON_DATA_BINARY;
8223
6804
  // Number of written bytes
8224
6805
  var numberOfWrittenBytes = !isArray
8225
6806
  ? buffer.write(key, index, undefined, 'utf8')
@@ -8232,7 +6813,7 @@ var BSON = (function (exports) {
8232
6813
  // Calculate size
8233
6814
  var size = value.position;
8234
6815
  // Add the deprecated 02 type 4 bytes of size to total
8235
- if (value.sub_type === binary.Binary.SUBTYPE_BYTE_ARRAY)
6816
+ if (value.sub_type === Binary.SUBTYPE_BYTE_ARRAY)
8236
6817
  size = size + 4;
8237
6818
  // Write the size of the string to buffer
8238
6819
  buffer[index++] = size & 0xff;
@@ -8242,7 +6823,7 @@ var BSON = (function (exports) {
8242
6823
  // Write the subtype to the buffer
8243
6824
  buffer[index++] = value.sub_type;
8244
6825
  // If we have binary type 2 the 4 first bytes are the size
8245
- if (value.sub_type === binary.Binary.SUBTYPE_BYTE_ARRAY) {
6826
+ if (value.sub_type === Binary.SUBTYPE_BYTE_ARRAY) {
8246
6827
  size = size - 4;
8247
6828
  buffer[index++] = size & 0xff;
8248
6829
  buffer[index++] = (size >> 8) & 0xff;
@@ -8257,7 +6838,7 @@ var BSON = (function (exports) {
8257
6838
  }
8258
6839
  function serializeSymbol(buffer, key, value, index, isArray) {
8259
6840
  // Write the type
8260
- buffer[index++] = constants.BSON_DATA_SYMBOL;
6841
+ buffer[index++] = BSON_DATA_SYMBOL;
8261
6842
  // Number of written bytes
8262
6843
  var numberOfWrittenBytes = !isArray
8263
6844
  ? buffer.write(key, index, undefined, 'utf8')
@@ -8280,7 +6861,7 @@ var BSON = (function (exports) {
8280
6861
  }
8281
6862
  function serializeDBRef(buffer, key, value, index, depth, serializeFunctions, isArray) {
8282
6863
  // Write the type
8283
- buffer[index++] = constants.BSON_DATA_OBJECT;
6864
+ buffer[index++] = BSON_DATA_OBJECT;
8284
6865
  // Number of written bytes
8285
6866
  var numberOfWrittenBytes = !isArray
8286
6867
  ? buffer.write(key, index, undefined, 'utf8')
@@ -8345,7 +6926,7 @@ var BSON = (function (exports) {
8345
6926
  else if (typeof value === 'boolean') {
8346
6927
  index = serializeBoolean(buffer, key, value, index, true);
8347
6928
  }
8348
- else if (value instanceof Date || utils.isDate(value)) {
6929
+ else if (value instanceof Date || isDate(value)) {
8349
6930
  index = serializeDate(buffer, key, value, index, true);
8350
6931
  }
8351
6932
  else if (value === undefined) {
@@ -8357,17 +6938,17 @@ var BSON = (function (exports) {
8357
6938
  else if (value['_bsontype'] === 'ObjectId' || value['_bsontype'] === 'ObjectID') {
8358
6939
  index = serializeObjectId(buffer, key, value, index, true);
8359
6940
  }
8360
- else if (utils.isUint8Array(value)) {
6941
+ else if (isUint8Array(value)) {
8361
6942
  index = serializeBuffer(buffer, key, value, index, true);
8362
6943
  }
8363
- else if (value instanceof RegExp || utils.isRegExp(value)) {
6944
+ else if (value instanceof RegExp || isRegExp(value)) {
8364
6945
  index = serializeRegExp(buffer, key, value, index, true);
8365
6946
  }
8366
6947
  else if (typeof value === 'object' && value['_bsontype'] == null) {
8367
6948
  index = serializeObject(buffer, key, value, index, checkKeys, depth, serializeFunctions, ignoreUndefined, true, path);
8368
6949
  }
8369
6950
  else if (typeof value === 'object' &&
8370
- extended_json.isBSONType(value) &&
6951
+ isBSONType(value) &&
8371
6952
  value._bsontype === 'Decimal128') {
8372
6953
  index = serializeDecimal128(buffer, key, value, index, true);
8373
6954
  }
@@ -8406,7 +6987,7 @@ var BSON = (function (exports) {
8406
6987
  }
8407
6988
  }
8408
6989
  }
8409
- else if (object instanceof map.Map || utils.isMap(object)) {
6990
+ else if (object instanceof exports.Map || isMap(object)) {
8410
6991
  var iterator = object.entries();
8411
6992
  var done = false;
8412
6993
  while (!done) {
@@ -8443,13 +7024,13 @@ var BSON = (function (exports) {
8443
7024
  else if (type === 'number') {
8444
7025
  index = serializeNumber(buffer, key, value, index);
8445
7026
  }
8446
- else if (type === 'bigint' || utils.isBigInt64Array(value) || utils.isBigUInt64Array(value)) {
7027
+ else if (type === 'bigint' || isBigInt64Array(value) || isBigUInt64Array(value)) {
8447
7028
  throw new TypeError('Unsupported type BigInt, please use Decimal128');
8448
7029
  }
8449
7030
  else if (type === 'boolean') {
8450
7031
  index = serializeBoolean(buffer, key, value, index);
8451
7032
  }
8452
- else if (value instanceof Date || utils.isDate(value)) {
7033
+ else if (value instanceof Date || isDate(value)) {
8453
7034
  index = serializeDate(buffer, key, value, index);
8454
7035
  }
8455
7036
  else if (value === null || (value === undefined && ignoreUndefined === false)) {
@@ -8458,10 +7039,10 @@ var BSON = (function (exports) {
8458
7039
  else if (value['_bsontype'] === 'ObjectId' || value['_bsontype'] === 'ObjectID') {
8459
7040
  index = serializeObjectId(buffer, key, value, index);
8460
7041
  }
8461
- else if (utils.isUint8Array(value)) {
7042
+ else if (isUint8Array(value)) {
8462
7043
  index = serializeBuffer(buffer, key, value, index);
8463
7044
  }
8464
- else if (value instanceof RegExp || utils.isRegExp(value)) {
7045
+ else if (value instanceof RegExp || isRegExp(value)) {
8465
7046
  index = serializeRegExp(buffer, key, value, index);
8466
7047
  }
8467
7048
  else if (type === 'object' && value['_bsontype'] == null) {
@@ -8553,7 +7134,7 @@ var BSON = (function (exports) {
8553
7134
  else if (type === 'boolean') {
8554
7135
  index = serializeBoolean(buffer, key, value, index);
8555
7136
  }
8556
- else if (value instanceof Date || utils.isDate(value)) {
7137
+ else if (value instanceof Date || isDate(value)) {
8557
7138
  index = serializeDate(buffer, key, value, index);
8558
7139
  }
8559
7140
  else if (value === undefined) {
@@ -8566,10 +7147,10 @@ var BSON = (function (exports) {
8566
7147
  else if (value['_bsontype'] === 'ObjectId' || value['_bsontype'] === 'ObjectID') {
8567
7148
  index = serializeObjectId(buffer, key, value, index);
8568
7149
  }
8569
- else if (utils.isUint8Array(value)) {
7150
+ else if (isUint8Array(value)) {
8570
7151
  index = serializeBuffer(buffer, key, value, index);
8571
7152
  }
8572
- else if (value instanceof RegExp || utils.isRegExp(value)) {
7153
+ else if (value instanceof RegExp || isRegExp(value)) {
8573
7154
  index = serializeRegExp(buffer, key, value, index);
8574
7155
  }
8575
7156
  else if (type === 'object' && value['_bsontype'] == null) {
@@ -8626,97 +7207,12 @@ var BSON = (function (exports) {
8626
7207
  buffer[startingIndex++] = (size >> 24) & 0xff;
8627
7208
  return index;
8628
7209
  }
8629
- exports.serializeInto = serializeInto;
8630
- //# sourceMappingURL=serializer.js.map
8631
- });
8632
-
8633
- unwrapExports(serializer);
8634
- serializer.serializeInto;
8635
-
8636
- var bson = createCommonjsModule(function (module, exports) {
8637
- Object.defineProperty(exports, "__esModule", { value: true });
8638
- exports.ObjectID = exports.Decimal128 = exports.BSONRegExp = exports.MaxKey = exports.MinKey = exports.Int32 = exports.Double = exports.Timestamp = exports.Long = exports.UUID = exports.ObjectId = exports.Binary = exports.DBRef = exports.BSONSymbol = exports.Map = exports.Code = exports.LongWithoutOverridesClass = exports.EJSON = exports.BSON_INT64_MIN = exports.BSON_INT64_MAX = exports.BSON_INT32_MIN = exports.BSON_INT32_MAX = exports.BSON_DATA_UNDEFINED = exports.BSON_DATA_TIMESTAMP = exports.BSON_DATA_SYMBOL = exports.BSON_DATA_STRING = exports.BSON_DATA_REGEXP = exports.BSON_DATA_OID = exports.BSON_DATA_OBJECT = exports.BSON_DATA_NUMBER = exports.BSON_DATA_NULL = exports.BSON_DATA_MIN_KEY = exports.BSON_DATA_MAX_KEY = exports.BSON_DATA_LONG = exports.BSON_DATA_INT = exports.BSON_DATA_DECIMAL128 = exports.BSON_DATA_DBPOINTER = exports.BSON_DATA_DATE = exports.BSON_DATA_CODE_W_SCOPE = exports.BSON_DATA_CODE = exports.BSON_DATA_BOOLEAN = exports.BSON_DATA_BINARY = exports.BSON_DATA_ARRAY = exports.BSON_BINARY_SUBTYPE_UUID_NEW = exports.BSON_BINARY_SUBTYPE_UUID = exports.BSON_BINARY_SUBTYPE_USER_DEFINED = exports.BSON_BINARY_SUBTYPE_MD5 = exports.BSON_BINARY_SUBTYPE_FUNCTION = exports.BSON_BINARY_SUBTYPE_DEFAULT = exports.BSON_BINARY_SUBTYPE_BYTE_ARRAY = void 0;
8639
- exports.deserializeStream = exports.calculateObjectSize = exports.deserialize = exports.serializeWithBufferAndIndex = exports.serialize = exports.setInternalBufferSize = void 0;
8640
-
8641
-
8642
- Object.defineProperty(exports, "Binary", { enumerable: true, get: function () { return binary.Binary; } });
8643
-
8644
- Object.defineProperty(exports, "Code", { enumerable: true, get: function () { return code.Code; } });
8645
-
8646
- Object.defineProperty(exports, "DBRef", { enumerable: true, get: function () { return db_ref.DBRef; } });
8647
-
8648
- Object.defineProperty(exports, "Decimal128", { enumerable: true, get: function () { return decimal128.Decimal128; } });
8649
-
8650
- Object.defineProperty(exports, "Double", { enumerable: true, get: function () { return double_1.Double; } });
8651
-
8652
-
8653
-
8654
- Object.defineProperty(exports, "Int32", { enumerable: true, get: function () { return int_32.Int32; } });
8655
-
8656
- Object.defineProperty(exports, "Long", { enumerable: true, get: function () { return long_1.Long; } });
8657
7210
 
8658
- Object.defineProperty(exports, "Map", { enumerable: true, get: function () { return map.Map; } });
8659
-
8660
- Object.defineProperty(exports, "MaxKey", { enumerable: true, get: function () { return max_key.MaxKey; } });
8661
-
8662
- Object.defineProperty(exports, "MinKey", { enumerable: true, get: function () { return min_key.MinKey; } });
8663
-
8664
- Object.defineProperty(exports, "ObjectId", { enumerable: true, get: function () { return objectid.ObjectId; } });
8665
- Object.defineProperty(exports, "ObjectID", { enumerable: true, get: function () { return objectid.ObjectId; } });
8666
-
8667
- // Parts of the parser
8668
-
8669
-
8670
-
8671
- Object.defineProperty(exports, "BSONRegExp", { enumerable: true, get: function () { return regexp.BSONRegExp; } });
8672
-
8673
- Object.defineProperty(exports, "BSONSymbol", { enumerable: true, get: function () { return symbol.BSONSymbol; } });
8674
-
8675
- Object.defineProperty(exports, "Timestamp", { enumerable: true, get: function () { return timestamp.Timestamp; } });
8676
-
8677
- Object.defineProperty(exports, "UUID", { enumerable: true, get: function () { return uuid.UUID; } });
8678
-
8679
- Object.defineProperty(exports, "BSON_BINARY_SUBTYPE_BYTE_ARRAY", { enumerable: true, get: function () { return constants.BSON_BINARY_SUBTYPE_BYTE_ARRAY; } });
8680
- Object.defineProperty(exports, "BSON_BINARY_SUBTYPE_DEFAULT", { enumerable: true, get: function () { return constants.BSON_BINARY_SUBTYPE_DEFAULT; } });
8681
- Object.defineProperty(exports, "BSON_BINARY_SUBTYPE_FUNCTION", { enumerable: true, get: function () { return constants.BSON_BINARY_SUBTYPE_FUNCTION; } });
8682
- Object.defineProperty(exports, "BSON_BINARY_SUBTYPE_MD5", { enumerable: true, get: function () { return constants.BSON_BINARY_SUBTYPE_MD5; } });
8683
- Object.defineProperty(exports, "BSON_BINARY_SUBTYPE_USER_DEFINED", { enumerable: true, get: function () { return constants.BSON_BINARY_SUBTYPE_USER_DEFINED; } });
8684
- Object.defineProperty(exports, "BSON_BINARY_SUBTYPE_UUID", { enumerable: true, get: function () { return constants.BSON_BINARY_SUBTYPE_UUID; } });
8685
- Object.defineProperty(exports, "BSON_BINARY_SUBTYPE_UUID_NEW", { enumerable: true, get: function () { return constants.BSON_BINARY_SUBTYPE_UUID_NEW; } });
8686
- Object.defineProperty(exports, "BSON_DATA_ARRAY", { enumerable: true, get: function () { return constants.BSON_DATA_ARRAY; } });
8687
- Object.defineProperty(exports, "BSON_DATA_BINARY", { enumerable: true, get: function () { return constants.BSON_DATA_BINARY; } });
8688
- Object.defineProperty(exports, "BSON_DATA_BOOLEAN", { enumerable: true, get: function () { return constants.BSON_DATA_BOOLEAN; } });
8689
- Object.defineProperty(exports, "BSON_DATA_CODE", { enumerable: true, get: function () { return constants.BSON_DATA_CODE; } });
8690
- Object.defineProperty(exports, "BSON_DATA_CODE_W_SCOPE", { enumerable: true, get: function () { return constants.BSON_DATA_CODE_W_SCOPE; } });
8691
- Object.defineProperty(exports, "BSON_DATA_DATE", { enumerable: true, get: function () { return constants.BSON_DATA_DATE; } });
8692
- Object.defineProperty(exports, "BSON_DATA_DBPOINTER", { enumerable: true, get: function () { return constants.BSON_DATA_DBPOINTER; } });
8693
- Object.defineProperty(exports, "BSON_DATA_DECIMAL128", { enumerable: true, get: function () { return constants.BSON_DATA_DECIMAL128; } });
8694
- Object.defineProperty(exports, "BSON_DATA_INT", { enumerable: true, get: function () { return constants.BSON_DATA_INT; } });
8695
- Object.defineProperty(exports, "BSON_DATA_LONG", { enumerable: true, get: function () { return constants.BSON_DATA_LONG; } });
8696
- Object.defineProperty(exports, "BSON_DATA_MAX_KEY", { enumerable: true, get: function () { return constants.BSON_DATA_MAX_KEY; } });
8697
- Object.defineProperty(exports, "BSON_DATA_MIN_KEY", { enumerable: true, get: function () { return constants.BSON_DATA_MIN_KEY; } });
8698
- Object.defineProperty(exports, "BSON_DATA_NULL", { enumerable: true, get: function () { return constants.BSON_DATA_NULL; } });
8699
- Object.defineProperty(exports, "BSON_DATA_NUMBER", { enumerable: true, get: function () { return constants.BSON_DATA_NUMBER; } });
8700
- Object.defineProperty(exports, "BSON_DATA_OBJECT", { enumerable: true, get: function () { return constants.BSON_DATA_OBJECT; } });
8701
- Object.defineProperty(exports, "BSON_DATA_OID", { enumerable: true, get: function () { return constants.BSON_DATA_OID; } });
8702
- Object.defineProperty(exports, "BSON_DATA_REGEXP", { enumerable: true, get: function () { return constants.BSON_DATA_REGEXP; } });
8703
- Object.defineProperty(exports, "BSON_DATA_STRING", { enumerable: true, get: function () { return constants.BSON_DATA_STRING; } });
8704
- Object.defineProperty(exports, "BSON_DATA_SYMBOL", { enumerable: true, get: function () { return constants.BSON_DATA_SYMBOL; } });
8705
- Object.defineProperty(exports, "BSON_DATA_TIMESTAMP", { enumerable: true, get: function () { return constants.BSON_DATA_TIMESTAMP; } });
8706
- Object.defineProperty(exports, "BSON_DATA_UNDEFINED", { enumerable: true, get: function () { return constants.BSON_DATA_UNDEFINED; } });
8707
- Object.defineProperty(exports, "BSON_INT32_MAX", { enumerable: true, get: function () { return constants.BSON_INT32_MAX; } });
8708
- Object.defineProperty(exports, "BSON_INT32_MIN", { enumerable: true, get: function () { return constants.BSON_INT32_MIN; } });
8709
- Object.defineProperty(exports, "BSON_INT64_MAX", { enumerable: true, get: function () { return constants.BSON_INT64_MAX; } });
8710
- Object.defineProperty(exports, "BSON_INT64_MIN", { enumerable: true, get: function () { return constants.BSON_INT64_MIN; } });
8711
- var extended_json_2 = extended_json;
8712
- Object.defineProperty(exports, "EJSON", { enumerable: true, get: function () { return extended_json_2.EJSON; } });
8713
- var timestamp_2 = timestamp;
8714
- Object.defineProperty(exports, "LongWithoutOverridesClass", { enumerable: true, get: function () { return timestamp_2.LongWithoutOverridesClass; } });
8715
7211
  /** @internal */
8716
7212
  // Default Max Size
8717
7213
  var MAXSIZE = 1024 * 1024 * 17;
8718
7214
  // Current Internal Temporary Serialization Buffer
8719
- var buffer$1 = buffer.Buffer.alloc(MAXSIZE);
7215
+ var buffer = buffer_1.alloc(MAXSIZE);
8720
7216
  /**
8721
7217
  * Sets the size of the internal serialization buffer.
8722
7218
  *
@@ -8725,11 +7221,10 @@ var BSON = (function (exports) {
8725
7221
  */
8726
7222
  function setInternalBufferSize(size) {
8727
7223
  // Resize the internal serialization buffer if needed
8728
- if (buffer$1.length < size) {
8729
- buffer$1 = buffer.Buffer.alloc(size);
7224
+ if (buffer.length < size) {
7225
+ buffer = buffer_1.alloc(size);
8730
7226
  }
8731
7227
  }
8732
- exports.setInternalBufferSize = setInternalBufferSize;
8733
7228
  /**
8734
7229
  * Serialize a Javascript object.
8735
7230
  *
@@ -8745,19 +7240,18 @@ var BSON = (function (exports) {
8745
7240
  var ignoreUndefined = typeof options.ignoreUndefined === 'boolean' ? options.ignoreUndefined : true;
8746
7241
  var minInternalBufferSize = typeof options.minInternalBufferSize === 'number' ? options.minInternalBufferSize : MAXSIZE;
8747
7242
  // Resize the internal serialization buffer if needed
8748
- if (buffer$1.length < minInternalBufferSize) {
8749
- buffer$1 = buffer.Buffer.alloc(minInternalBufferSize);
7243
+ if (buffer.length < minInternalBufferSize) {
7244
+ buffer = buffer_1.alloc(minInternalBufferSize);
8750
7245
  }
8751
7246
  // Attempt to serialize
8752
- var serializationIndex = serializer.serializeInto(buffer$1, object, checkKeys, 0, 0, serializeFunctions, ignoreUndefined, []);
7247
+ var serializationIndex = serializeInto(buffer, object, checkKeys, 0, 0, serializeFunctions, ignoreUndefined, []);
8753
7248
  // Create the final buffer
8754
- var finishedBuffer = buffer.Buffer.alloc(serializationIndex);
7249
+ var finishedBuffer = buffer_1.alloc(serializationIndex);
8755
7250
  // Copy into the finished buffer
8756
- buffer$1.copy(finishedBuffer, 0, 0, finishedBuffer.length);
7251
+ buffer.copy(finishedBuffer, 0, 0, finishedBuffer.length);
8757
7252
  // Return the buffer
8758
7253
  return finishedBuffer;
8759
7254
  }
8760
- exports.serialize = serialize;
8761
7255
  /**
8762
7256
  * Serialize a Javascript object using a predefined Buffer and index into the buffer,
8763
7257
  * useful when pre-allocating the space for serialization.
@@ -8775,12 +7269,11 @@ var BSON = (function (exports) {
8775
7269
  var ignoreUndefined = typeof options.ignoreUndefined === 'boolean' ? options.ignoreUndefined : true;
8776
7270
  var startIndex = typeof options.index === 'number' ? options.index : 0;
8777
7271
  // Attempt to serialize
8778
- var serializationIndex = serializer.serializeInto(buffer$1, object, checkKeys, 0, 0, serializeFunctions, ignoreUndefined);
8779
- buffer$1.copy(finalBuffer, startIndex, 0, serializationIndex);
7272
+ var serializationIndex = serializeInto(buffer, object, checkKeys, 0, 0, serializeFunctions, ignoreUndefined);
7273
+ buffer.copy(finalBuffer, startIndex, 0, serializationIndex);
8780
7274
  // Return the index
8781
7275
  return startIndex + serializationIndex - 1;
8782
7276
  }
8783
- exports.serializeWithBufferAndIndex = serializeWithBufferAndIndex;
8784
7277
  /**
8785
7278
  * Deserialize data as BSON.
8786
7279
  *
@@ -8790,9 +7283,8 @@ var BSON = (function (exports) {
8790
7283
  */
8791
7284
  function deserialize(buffer, options) {
8792
7285
  if (options === void 0) { options = {}; }
8793
- return deserializer.deserialize(ensure_buffer.ensureBuffer(buffer), options);
7286
+ return deserialize$1(buffer instanceof buffer_1 ? buffer : ensureBuffer(buffer), options);
8794
7287
  }
8795
- exports.deserialize = deserialize;
8796
7288
  /**
8797
7289
  * Calculate the bson size for a passed in Javascript object.
8798
7290
  *
@@ -8805,9 +7297,8 @@ var BSON = (function (exports) {
8805
7297
  options = options || {};
8806
7298
  var serializeFunctions = typeof options.serializeFunctions === 'boolean' ? options.serializeFunctions : false;
8807
7299
  var ignoreUndefined = typeof options.ignoreUndefined === 'boolean' ? options.ignoreUndefined : true;
8808
- return calculate_size.calculateObjectSize(object, serializeFunctions, ignoreUndefined);
7300
+ return calculateObjectSize$1(object, serializeFunctions, ignoreUndefined);
8809
7301
  }
8810
- exports.calculateObjectSize = calculateObjectSize;
8811
7302
  /**
8812
7303
  * Deserialize stream data as BSON documents.
8813
7304
  *
@@ -8822,7 +7313,7 @@ var BSON = (function (exports) {
8822
7313
  */
8823
7314
  function deserializeStream(data, startIndex, numberOfDocuments, documents, docStartIndex, options) {
8824
7315
  var internalOptions = Object.assign({ allowObjectSmallerThanBufferSize: true, index: 0 }, options);
8825
- var bufferData = ensure_buffer.ensureBuffer(data);
7316
+ var bufferData = ensureBuffer(data);
8826
7317
  var index = startIndex;
8827
7318
  // Loop over all documents
8828
7319
  for (var i = 0; i < numberOfDocuments; i++) {
@@ -8834,14 +7325,13 @@ var BSON = (function (exports) {
8834
7325
  // Update options with index
8835
7326
  internalOptions.index = index;
8836
7327
  // Parse the document at this point
8837
- documents[docStartIndex + i] = deserializer.deserialize(bufferData, internalOptions);
7328
+ documents[docStartIndex + i] = deserialize$1(bufferData, internalOptions);
8838
7329
  // Adjust index by the document size
8839
7330
  index = index + size;
8840
7331
  }
8841
7332
  // Return object containing end index of parsing and list of documents
8842
7333
  return index;
8843
7334
  }
8844
- exports.deserializeStream = deserializeStream;
8845
7335
  /**
8846
7336
  * BSON default export
8847
7337
  * @deprecated Please use named exports
@@ -8851,23 +7341,23 @@ var BSON = (function (exports) {
8851
7341
  * @public
8852
7342
  */
8853
7343
  var BSON = {
8854
- Binary: binary.Binary,
8855
- Code: code.Code,
8856
- DBRef: db_ref.DBRef,
8857
- Decimal128: decimal128.Decimal128,
8858
- Double: double_1.Double,
8859
- Int32: int_32.Int32,
8860
- Long: long_1.Long,
8861
- UUID: uuid.UUID,
8862
- Map: map.Map,
8863
- MaxKey: max_key.MaxKey,
8864
- MinKey: min_key.MinKey,
8865
- ObjectId: objectid.ObjectId,
8866
- ObjectID: objectid.ObjectId,
8867
- BSONRegExp: regexp.BSONRegExp,
8868
- BSONSymbol: symbol.BSONSymbol,
8869
- Timestamp: timestamp.Timestamp,
8870
- EJSON: extended_json.EJSON,
7344
+ Binary: Binary,
7345
+ Code: Code,
7346
+ DBRef: DBRef,
7347
+ Decimal128: Decimal128,
7348
+ Double: Double,
7349
+ Int32: Int32,
7350
+ Long: Long,
7351
+ UUID: UUID,
7352
+ Map: exports.Map,
7353
+ MaxKey: MaxKey,
7354
+ MinKey: MinKey,
7355
+ ObjectId: ObjectId,
7356
+ ObjectID: ObjectId,
7357
+ BSONRegExp: BSONRegExp,
7358
+ BSONSymbol: BSONSymbol,
7359
+ Timestamp: Timestamp,
7360
+ EJSON: exports.EJSON,
8871
7361
  setInternalBufferSize: setInternalBufferSize,
8872
7362
  serialize: serialize,
8873
7363
  serializeWithBufferAndIndex: serializeWithBufferAndIndex,
@@ -8875,125 +7365,62 @@ var BSON = (function (exports) {
8875
7365
  calculateObjectSize: calculateObjectSize,
8876
7366
  deserializeStream: deserializeStream
8877
7367
  };
8878
- exports.default = BSON;
8879
- //# sourceMappingURL=bson.js.map
8880
- });
8881
7368
 
8882
- var bson$1 = unwrapExports(bson);
8883
- var bson_1 = bson.ObjectID;
8884
- var bson_2 = bson.Decimal128;
8885
- var bson_3 = bson.BSONRegExp;
8886
- var bson_4 = bson.MaxKey;
8887
- var bson_5 = bson.MinKey;
8888
- var bson_6 = bson.Int32;
8889
- var bson_7 = bson.Double;
8890
- var bson_8 = bson.Timestamp;
8891
- var bson_9 = bson.Long;
8892
- var bson_10 = bson.UUID;
8893
- var bson_11 = bson.ObjectId;
8894
- var bson_12 = bson.Binary;
8895
- var bson_13 = bson.DBRef;
8896
- var bson_14 = bson.BSONSymbol;
8897
- var bson_15 = bson.Map;
8898
- var bson_16 = bson.Code;
8899
- var bson_17 = bson.LongWithoutOverridesClass;
8900
- var bson_18 = bson.EJSON;
8901
- var bson_19 = bson.BSON_INT64_MIN;
8902
- var bson_20 = bson.BSON_INT64_MAX;
8903
- var bson_21 = bson.BSON_INT32_MIN;
8904
- var bson_22 = bson.BSON_INT32_MAX;
8905
- var bson_23 = bson.BSON_DATA_UNDEFINED;
8906
- var bson_24 = bson.BSON_DATA_TIMESTAMP;
8907
- var bson_25 = bson.BSON_DATA_SYMBOL;
8908
- var bson_26 = bson.BSON_DATA_STRING;
8909
- var bson_27 = bson.BSON_DATA_REGEXP;
8910
- var bson_28 = bson.BSON_DATA_OID;
8911
- var bson_29 = bson.BSON_DATA_OBJECT;
8912
- var bson_30 = bson.BSON_DATA_NUMBER;
8913
- var bson_31 = bson.BSON_DATA_NULL;
8914
- var bson_32 = bson.BSON_DATA_MIN_KEY;
8915
- var bson_33 = bson.BSON_DATA_MAX_KEY;
8916
- var bson_34 = bson.BSON_DATA_LONG;
8917
- var bson_35 = bson.BSON_DATA_INT;
8918
- var bson_36 = bson.BSON_DATA_DECIMAL128;
8919
- var bson_37 = bson.BSON_DATA_DBPOINTER;
8920
- var bson_38 = bson.BSON_DATA_DATE;
8921
- var bson_39 = bson.BSON_DATA_CODE_W_SCOPE;
8922
- var bson_40 = bson.BSON_DATA_CODE;
8923
- var bson_41 = bson.BSON_DATA_BOOLEAN;
8924
- var bson_42 = bson.BSON_DATA_BINARY;
8925
- var bson_43 = bson.BSON_DATA_ARRAY;
8926
- var bson_44 = bson.BSON_BINARY_SUBTYPE_UUID_NEW;
8927
- var bson_45 = bson.BSON_BINARY_SUBTYPE_UUID;
8928
- var bson_46 = bson.BSON_BINARY_SUBTYPE_USER_DEFINED;
8929
- var bson_47 = bson.BSON_BINARY_SUBTYPE_MD5;
8930
- var bson_48 = bson.BSON_BINARY_SUBTYPE_FUNCTION;
8931
- var bson_49 = bson.BSON_BINARY_SUBTYPE_DEFAULT;
8932
- var bson_50 = bson.BSON_BINARY_SUBTYPE_BYTE_ARRAY;
8933
- var bson_51 = bson.deserializeStream;
8934
- var bson_52 = bson.calculateObjectSize;
8935
- var bson_53 = bson.deserialize;
8936
- var bson_54 = bson.serializeWithBufferAndIndex;
8937
- var bson_55 = bson.serialize;
8938
- var bson_56 = bson.setInternalBufferSize;
8939
-
8940
- exports.BSONRegExp = bson_3;
8941
- exports.BSONSymbol = bson_14;
8942
- exports.BSON_BINARY_SUBTYPE_BYTE_ARRAY = bson_50;
8943
- exports.BSON_BINARY_SUBTYPE_DEFAULT = bson_49;
8944
- exports.BSON_BINARY_SUBTYPE_FUNCTION = bson_48;
8945
- exports.BSON_BINARY_SUBTYPE_MD5 = bson_47;
8946
- exports.BSON_BINARY_SUBTYPE_USER_DEFINED = bson_46;
8947
- exports.BSON_BINARY_SUBTYPE_UUID = bson_45;
8948
- exports.BSON_BINARY_SUBTYPE_UUID_NEW = bson_44;
8949
- exports.BSON_DATA_ARRAY = bson_43;
8950
- exports.BSON_DATA_BINARY = bson_42;
8951
- exports.BSON_DATA_BOOLEAN = bson_41;
8952
- exports.BSON_DATA_CODE = bson_40;
8953
- exports.BSON_DATA_CODE_W_SCOPE = bson_39;
8954
- exports.BSON_DATA_DATE = bson_38;
8955
- exports.BSON_DATA_DBPOINTER = bson_37;
8956
- exports.BSON_DATA_DECIMAL128 = bson_36;
8957
- exports.BSON_DATA_INT = bson_35;
8958
- exports.BSON_DATA_LONG = bson_34;
8959
- exports.BSON_DATA_MAX_KEY = bson_33;
8960
- exports.BSON_DATA_MIN_KEY = bson_32;
8961
- exports.BSON_DATA_NULL = bson_31;
8962
- exports.BSON_DATA_NUMBER = bson_30;
8963
- exports.BSON_DATA_OBJECT = bson_29;
8964
- exports.BSON_DATA_OID = bson_28;
8965
- exports.BSON_DATA_REGEXP = bson_27;
8966
- exports.BSON_DATA_STRING = bson_26;
8967
- exports.BSON_DATA_SYMBOL = bson_25;
8968
- exports.BSON_DATA_TIMESTAMP = bson_24;
8969
- exports.BSON_DATA_UNDEFINED = bson_23;
8970
- exports.BSON_INT32_MAX = bson_22;
8971
- exports.BSON_INT32_MIN = bson_21;
8972
- exports.BSON_INT64_MAX = bson_20;
8973
- exports.BSON_INT64_MIN = bson_19;
8974
- exports.Binary = bson_12;
8975
- exports.Code = bson_16;
8976
- exports.DBRef = bson_13;
8977
- exports.Decimal128 = bson_2;
8978
- exports.Double = bson_7;
8979
- exports.EJSON = bson_18;
8980
- exports.Int32 = bson_6;
8981
- exports.Long = bson_9;
8982
- exports.LongWithoutOverridesClass = bson_17;
8983
- exports.Map = bson_15;
8984
- exports.MaxKey = bson_4;
8985
- exports.MinKey = bson_5;
8986
- exports.ObjectID = bson_1;
8987
- exports.ObjectId = bson_11;
8988
- exports.Timestamp = bson_8;
8989
- exports.UUID = bson_10;
8990
- exports.calculateObjectSize = bson_52;
8991
- exports.default = bson$1;
8992
- exports.deserialize = bson_53;
8993
- exports.deserializeStream = bson_51;
8994
- exports.serialize = bson_55;
8995
- exports.serializeWithBufferAndIndex = bson_54;
8996
- exports.setInternalBufferSize = bson_56;
7369
+ exports.BSONRegExp = BSONRegExp;
7370
+ exports.BSONSymbol = BSONSymbol;
7371
+ exports.BSON_BINARY_SUBTYPE_BYTE_ARRAY = BSON_BINARY_SUBTYPE_BYTE_ARRAY;
7372
+ exports.BSON_BINARY_SUBTYPE_DEFAULT = BSON_BINARY_SUBTYPE_DEFAULT;
7373
+ exports.BSON_BINARY_SUBTYPE_FUNCTION = BSON_BINARY_SUBTYPE_FUNCTION;
7374
+ exports.BSON_BINARY_SUBTYPE_MD5 = BSON_BINARY_SUBTYPE_MD5;
7375
+ exports.BSON_BINARY_SUBTYPE_USER_DEFINED = BSON_BINARY_SUBTYPE_USER_DEFINED;
7376
+ exports.BSON_BINARY_SUBTYPE_UUID = BSON_BINARY_SUBTYPE_UUID;
7377
+ exports.BSON_BINARY_SUBTYPE_UUID_NEW = BSON_BINARY_SUBTYPE_UUID_NEW;
7378
+ exports.BSON_DATA_ARRAY = BSON_DATA_ARRAY;
7379
+ exports.BSON_DATA_BINARY = BSON_DATA_BINARY;
7380
+ exports.BSON_DATA_BOOLEAN = BSON_DATA_BOOLEAN;
7381
+ exports.BSON_DATA_CODE = BSON_DATA_CODE;
7382
+ exports.BSON_DATA_CODE_W_SCOPE = BSON_DATA_CODE_W_SCOPE;
7383
+ exports.BSON_DATA_DATE = BSON_DATA_DATE;
7384
+ exports.BSON_DATA_DBPOINTER = BSON_DATA_DBPOINTER;
7385
+ exports.BSON_DATA_DECIMAL128 = BSON_DATA_DECIMAL128;
7386
+ exports.BSON_DATA_INT = BSON_DATA_INT;
7387
+ exports.BSON_DATA_LONG = BSON_DATA_LONG;
7388
+ exports.BSON_DATA_MAX_KEY = BSON_DATA_MAX_KEY;
7389
+ exports.BSON_DATA_MIN_KEY = BSON_DATA_MIN_KEY;
7390
+ exports.BSON_DATA_NULL = BSON_DATA_NULL;
7391
+ exports.BSON_DATA_NUMBER = BSON_DATA_NUMBER;
7392
+ exports.BSON_DATA_OBJECT = BSON_DATA_OBJECT;
7393
+ exports.BSON_DATA_OID = BSON_DATA_OID;
7394
+ exports.BSON_DATA_REGEXP = BSON_DATA_REGEXP;
7395
+ exports.BSON_DATA_STRING = BSON_DATA_STRING;
7396
+ exports.BSON_DATA_SYMBOL = BSON_DATA_SYMBOL;
7397
+ exports.BSON_DATA_TIMESTAMP = BSON_DATA_TIMESTAMP;
7398
+ exports.BSON_DATA_UNDEFINED = BSON_DATA_UNDEFINED;
7399
+ exports.BSON_INT32_MAX = BSON_INT32_MAX;
7400
+ exports.BSON_INT32_MIN = BSON_INT32_MIN;
7401
+ exports.BSON_INT64_MAX = BSON_INT64_MAX;
7402
+ exports.BSON_INT64_MIN = BSON_INT64_MIN;
7403
+ exports.Binary = Binary;
7404
+ exports.Code = Code;
7405
+ exports.DBRef = DBRef;
7406
+ exports.Decimal128 = Decimal128;
7407
+ exports.Double = Double;
7408
+ exports.Int32 = Int32;
7409
+ exports.Long = Long;
7410
+ exports.LongWithoutOverridesClass = LongWithoutOverridesClass;
7411
+ exports.MaxKey = MaxKey;
7412
+ exports.MinKey = MinKey;
7413
+ exports.ObjectID = ObjectId;
7414
+ exports.ObjectId = ObjectId;
7415
+ exports.Timestamp = Timestamp;
7416
+ exports.UUID = UUID;
7417
+ exports.calculateObjectSize = calculateObjectSize;
7418
+ exports.default = BSON;
7419
+ exports.deserialize = deserialize;
7420
+ exports.deserializeStream = deserializeStream;
7421
+ exports.serialize = serialize;
7422
+ exports.serializeWithBufferAndIndex = serializeWithBufferAndIndex;
7423
+ exports.setInternalBufferSize = setInternalBufferSize;
8997
7424
 
8998
7425
  Object.defineProperty(exports, '__esModule', { value: true });
8999
7426