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
package/dist/bson.esm.js CHANGED
@@ -1,573 +1,19 @@
1
- import buffer from 'buffer';
1
+ import { Buffer } from 'buffer';
2
2
 
3
- var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
4
-
5
- function unwrapExports (x) {
6
- return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
7
- }
8
-
9
- function createCommonjsModule(fn, module) {
10
- return module = { exports: {} }, fn(module, module.exports), module.exports;
11
- }
12
-
13
- var require$$0 = {};
14
-
15
- var inherits;
16
-
17
- if (typeof Object.create === 'function') {
18
- inherits = function inherits(ctor, superCtor) {
19
- // implementation from standard node.js 'util' module
20
- ctor.super_ = superCtor;
21
- ctor.prototype = Object.create(superCtor.prototype, {
22
- constructor: {
23
- value: ctor,
24
- enumerable: false,
25
- writable: true,
26
- configurable: true
27
- }
28
- });
29
- };
30
- } else {
31
- inherits = function inherits(ctor, superCtor) {
32
- ctor.super_ = superCtor;
33
-
34
- var TempCtor = function TempCtor() {};
35
-
36
- TempCtor.prototype = superCtor.prototype;
37
- ctor.prototype = new TempCtor();
38
- ctor.prototype.constructor = ctor;
39
- };
40
- }
41
-
42
- var inherits$1 = inherits;
43
-
44
- // Copyright Joyent, Inc. and other Node contributors.
45
- var formatRegExp = /%[sdj%]/g;
46
- function format(f) {
47
- if (!isString(f)) {
48
- var objects = [];
49
-
50
- for (var i = 0; i < arguments.length; i++) {
51
- objects.push(inspect(arguments[i]));
52
- }
53
-
54
- return objects.join(' ');
55
- }
56
-
57
- var i = 1;
58
- var args = arguments;
59
- var len = args.length;
60
- var str = String(f).replace(formatRegExp, function (x) {
61
- if (x === '%%') return '%';
62
- if (i >= len) return x;
63
-
64
- switch (x) {
65
- case '%s':
66
- return String(args[i++]);
67
-
68
- case '%d':
69
- return Number(args[i++]);
70
-
71
- case '%j':
72
- try {
73
- return JSON.stringify(args[i++]);
74
- } catch (_) {
75
- return '[Circular]';
76
- }
77
-
78
- default:
79
- return x;
80
- }
81
- });
82
-
83
- for (var x = args[i]; i < len; x = args[++i]) {
84
- if (isNull(x) || !isObject(x)) {
85
- str += ' ' + x;
86
- } else {
87
- str += ' ' + inspect(x);
88
- }
89
- }
90
-
91
- return str;
92
- }
93
- // Returns a modified function which warns once by default.
94
- // If --no-deprecation is set, then it is a no-op.
95
-
96
- function deprecate(fn, msg) {
97
- // Allow for deprecating things in the process of starting up.
98
- if (isUndefined(global.process)) {
99
- return function () {
100
- return deprecate(fn, msg).apply(this, arguments);
101
- };
102
- }
103
-
104
- var warned = false;
105
-
106
- function deprecated() {
107
- if (!warned) {
108
- {
109
- console.error(msg);
110
- }
111
-
112
- warned = true;
113
- }
114
-
115
- return fn.apply(this, arguments);
116
- }
117
-
118
- return deprecated;
119
- }
120
- var debugs = {};
121
- var debugEnviron;
122
- function debuglog(set) {
123
- if (isUndefined(debugEnviron)) debugEnviron = '';
124
- set = set.toUpperCase();
125
-
126
- if (!debugs[set]) {
127
- if (new RegExp('\\b' + set + '\\b', 'i').test(debugEnviron)) {
128
- var pid = 0;
129
-
130
- debugs[set] = function () {
131
- var msg = format.apply(null, arguments);
132
- console.error('%s %d: %s', set, pid, msg);
133
- };
134
- } else {
135
- debugs[set] = function () {};
136
- }
137
- }
138
-
139
- return debugs[set];
140
- }
141
- /**
142
- * Echos the value of a value. Trys to print the value out
143
- * in the best way possible given the different types.
144
- *
145
- * @param {Object} obj The object to print out.
146
- * @param {Object} opts Optional options object that alters the output.
147
- */
148
-
149
- /* legacy: obj, showHidden, depth, colors*/
150
-
151
- function inspect(obj, opts) {
152
- // default options
153
- var ctx = {
154
- seen: [],
155
- stylize: stylizeNoColor
156
- }; // legacy...
157
-
158
- if (arguments.length >= 3) ctx.depth = arguments[2];
159
- if (arguments.length >= 4) ctx.colors = arguments[3];
160
-
161
- if (isBoolean(opts)) {
162
- // legacy...
163
- ctx.showHidden = opts;
164
- } else if (opts) {
165
- // got an "options" object
166
- _extend(ctx, opts);
167
- } // set default options
168
-
169
-
170
- if (isUndefined(ctx.showHidden)) ctx.showHidden = false;
171
- if (isUndefined(ctx.depth)) ctx.depth = 2;
172
- if (isUndefined(ctx.colors)) ctx.colors = false;
173
- if (isUndefined(ctx.customInspect)) ctx.customInspect = true;
174
- if (ctx.colors) ctx.stylize = stylizeWithColor;
175
- return formatValue(ctx, obj, ctx.depth);
176
- } // http://en.wikipedia.org/wiki/ANSI_escape_code#graphics
177
-
178
- inspect.colors = {
179
- 'bold': [1, 22],
180
- 'italic': [3, 23],
181
- 'underline': [4, 24],
182
- 'inverse': [7, 27],
183
- 'white': [37, 39],
184
- 'grey': [90, 39],
185
- 'black': [30, 39],
186
- 'blue': [34, 39],
187
- 'cyan': [36, 39],
188
- 'green': [32, 39],
189
- 'magenta': [35, 39],
190
- 'red': [31, 39],
191
- 'yellow': [33, 39]
192
- }; // Don't use 'blue' not visible on cmd.exe
193
-
194
- inspect.styles = {
195
- 'special': 'cyan',
196
- 'number': 'yellow',
197
- 'boolean': 'yellow',
198
- 'undefined': 'grey',
199
- 'null': 'bold',
200
- 'string': 'green',
201
- 'date': 'magenta',
202
- // "name": intentionally not styling
203
- 'regexp': 'red'
204
- };
205
-
206
- function stylizeWithColor(str, styleType) {
207
- var style = inspect.styles[styleType];
208
-
209
- if (style) {
210
- return "\x1B[" + inspect.colors[style][0] + 'm' + str + "\x1B[" + inspect.colors[style][1] + 'm';
211
- } else {
212
- return str;
213
- }
214
- }
215
-
216
- function stylizeNoColor(str, styleType) {
217
- return str;
218
- }
219
-
220
- function arrayToHash(array) {
221
- var hash = {};
222
- array.forEach(function (val, idx) {
223
- hash[val] = true;
224
- });
225
- return hash;
226
- }
227
-
228
- function formatValue(ctx, value, recurseTimes) {
229
- // Provide a hook for user-specified inspect functions.
230
- // Check that value is an object with an inspect function on it
231
- if (ctx.customInspect && value && isFunction(value.inspect) && // Filter out the util module, it's inspect function is special
232
- value.inspect !== inspect && // Also filter out any prototype objects using the circular check.
233
- !(value.constructor && value.constructor.prototype === value)) {
234
- var ret = value.inspect(recurseTimes, ctx);
235
-
236
- if (!isString(ret)) {
237
- ret = formatValue(ctx, ret, recurseTimes);
238
- }
239
-
240
- return ret;
241
- } // Primitive types cannot have properties
242
-
243
-
244
- var primitive = formatPrimitive(ctx, value);
245
-
246
- if (primitive) {
247
- return primitive;
248
- } // Look up the keys of the object.
249
-
250
-
251
- var keys = Object.keys(value);
252
- var visibleKeys = arrayToHash(keys);
253
-
254
- if (ctx.showHidden) {
255
- keys = Object.getOwnPropertyNames(value);
256
- } // IE doesn't make error fields non-enumerable
257
- // http://msdn.microsoft.com/en-us/library/ie/dww52sbt(v=vs.94).aspx
258
-
259
-
260
- if (isError(value) && (keys.indexOf('message') >= 0 || keys.indexOf('description') >= 0)) {
261
- return formatError(value);
262
- } // Some type of object without properties can be shortcutted.
263
-
264
-
265
- if (keys.length === 0) {
266
- if (isFunction(value)) {
267
- var name = value.name ? ': ' + value.name : '';
268
- return ctx.stylize('[Function' + name + ']', 'special');
269
- }
270
-
271
- if (isRegExp(value)) {
272
- return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
273
- }
274
-
275
- if (isDate(value)) {
276
- return ctx.stylize(Date.prototype.toString.call(value), 'date');
277
- }
278
-
279
- if (isError(value)) {
280
- return formatError(value);
281
- }
282
- }
283
-
284
- var base = '',
285
- array = false,
286
- braces = ['{', '}']; // Make Array say that they are Array
287
-
288
- if (isArray(value)) {
289
- array = true;
290
- braces = ['[', ']'];
291
- } // Make functions say that they are functions
292
-
293
-
294
- if (isFunction(value)) {
295
- var n = value.name ? ': ' + value.name : '';
296
- base = ' [Function' + n + ']';
297
- } // Make RegExps say that they are RegExps
298
-
299
-
300
- if (isRegExp(value)) {
301
- base = ' ' + RegExp.prototype.toString.call(value);
302
- } // Make dates with properties first say the date
303
-
304
-
305
- if (isDate(value)) {
306
- base = ' ' + Date.prototype.toUTCString.call(value);
307
- } // Make error with message first say the error
308
-
309
-
310
- if (isError(value)) {
311
- base = ' ' + formatError(value);
312
- }
313
-
314
- if (keys.length === 0 && (!array || value.length == 0)) {
315
- return braces[0] + base + braces[1];
316
- }
317
-
318
- if (recurseTimes < 0) {
319
- if (isRegExp(value)) {
320
- return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
321
- } else {
322
- return ctx.stylize('[Object]', 'special');
323
- }
324
- }
325
-
326
- ctx.seen.push(value);
327
- var output;
328
-
329
- if (array) {
330
- output = formatArray(ctx, value, recurseTimes, visibleKeys, keys);
331
- } else {
332
- output = keys.map(function (key) {
333
- return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array);
334
- });
335
- }
336
-
337
- ctx.seen.pop();
338
- return reduceToSingleString(output, base, braces);
339
- }
340
-
341
- function formatPrimitive(ctx, value) {
342
- if (isUndefined(value)) return ctx.stylize('undefined', 'undefined');
343
-
344
- if (isString(value)) {
345
- var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '').replace(/'/g, "\\'").replace(/\\"/g, '"') + '\'';
346
- return ctx.stylize(simple, 'string');
347
- }
348
-
349
- if (isNumber(value)) return ctx.stylize('' + value, 'number');
350
- if (isBoolean(value)) return ctx.stylize('' + value, 'boolean'); // For some reason typeof null is "object", so special case here.
351
-
352
- if (isNull(value)) return ctx.stylize('null', 'null');
353
- }
354
-
355
- function formatError(value) {
356
- return '[' + Error.prototype.toString.call(value) + ']';
357
- }
358
-
359
- function formatArray(ctx, value, recurseTimes, visibleKeys, keys) {
360
- var output = [];
361
-
362
- for (var i = 0, l = value.length; i < l; ++i) {
363
- if (hasOwnProperty(value, String(i))) {
364
- output.push(formatProperty(ctx, value, recurseTimes, visibleKeys, String(i), true));
365
- } else {
366
- output.push('');
367
- }
368
- }
369
-
370
- keys.forEach(function (key) {
371
- if (!key.match(/^\d+$/)) {
372
- output.push(formatProperty(ctx, value, recurseTimes, visibleKeys, key, true));
373
- }
374
- });
375
- return output;
376
- }
377
-
378
- function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) {
379
- var name, str, desc;
380
- desc = Object.getOwnPropertyDescriptor(value, key) || {
381
- value: value[key]
382
- };
383
-
384
- if (desc.get) {
385
- if (desc.set) {
386
- str = ctx.stylize('[Getter/Setter]', 'special');
387
- } else {
388
- str = ctx.stylize('[Getter]', 'special');
389
- }
390
- } else {
391
- if (desc.set) {
392
- str = ctx.stylize('[Setter]', 'special');
393
- }
394
- }
395
-
396
- if (!hasOwnProperty(visibleKeys, key)) {
397
- name = '[' + key + ']';
398
- }
399
-
400
- if (!str) {
401
- if (ctx.seen.indexOf(desc.value) < 0) {
402
- if (isNull(recurseTimes)) {
403
- str = formatValue(ctx, desc.value, null);
404
- } else {
405
- str = formatValue(ctx, desc.value, recurseTimes - 1);
406
- }
407
-
408
- if (str.indexOf('\n') > -1) {
409
- if (array) {
410
- str = str.split('\n').map(function (line) {
411
- return ' ' + line;
412
- }).join('\n').substr(2);
413
- } else {
414
- str = '\n' + str.split('\n').map(function (line) {
415
- return ' ' + line;
416
- }).join('\n');
417
- }
418
- }
419
- } else {
420
- str = ctx.stylize('[Circular]', 'special');
421
- }
422
- }
423
-
424
- if (isUndefined(name)) {
425
- if (array && key.match(/^\d+$/)) {
426
- return str;
427
- }
428
-
429
- name = JSON.stringify('' + key);
430
-
431
- if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) {
432
- name = name.substr(1, name.length - 2);
433
- name = ctx.stylize(name, 'name');
434
- } else {
435
- name = name.replace(/'/g, "\\'").replace(/\\"/g, '"').replace(/(^"|"$)/g, "'");
436
- name = ctx.stylize(name, 'string');
437
- }
438
- }
439
-
440
- return name + ': ' + str;
441
- }
442
-
443
- function reduceToSingleString(output, base, braces) {
444
- var length = output.reduce(function (prev, cur) {
445
- if (cur.indexOf('\n') >= 0) ;
446
- return prev + cur.replace(/\u001b\[\d\d?m/g, '').length + 1;
447
- }, 0);
448
-
449
- if (length > 60) {
450
- return braces[0] + (base === '' ? '' : base + '\n ') + ' ' + output.join(',\n ') + ' ' + braces[1];
451
- }
452
-
453
- return braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1];
454
- } // NOTE: These type checking functions intentionally don't use `instanceof`
455
- // because it is fragile and can be easily faked with `Object.create()`.
456
-
457
-
458
- function isArray(ar) {
459
- return Array.isArray(ar);
460
- }
461
- function isBoolean(arg) {
462
- return typeof arg === 'boolean';
463
- }
464
- function isNull(arg) {
465
- return arg === null;
466
- }
467
- function isNullOrUndefined(arg) {
468
- return arg == null;
469
- }
470
- function isNumber(arg) {
471
- return typeof arg === 'number';
472
- }
473
- function isString(arg) {
474
- return typeof arg === 'string';
475
- }
476
- function isSymbol(arg) {
477
- return babelHelpers["typeof"](arg) === 'symbol';
478
- }
479
- function isUndefined(arg) {
480
- return arg === void 0;
481
- }
482
- function isRegExp(re) {
483
- return isObject(re) && objectToString(re) === '[object RegExp]';
484
- }
485
- function isObject(arg) {
486
- return babelHelpers["typeof"](arg) === 'object' && arg !== null;
487
- }
488
- function isDate(d) {
489
- return isObject(d) && objectToString(d) === '[object Date]';
490
- }
491
- function isError(e) {
492
- return isObject(e) && (objectToString(e) === '[object Error]' || e instanceof Error);
493
- }
494
- function isFunction(arg) {
495
- return typeof arg === 'function';
496
- }
497
- function isPrimitive(arg) {
498
- return arg === null || typeof arg === 'boolean' || typeof arg === 'number' || typeof arg === 'string' || babelHelpers["typeof"](arg) === 'symbol' || // ES6 symbol
499
- typeof arg === 'undefined';
500
- }
501
- function isBuffer(maybeBuf) {
502
- return Buffer.isBuffer(maybeBuf);
503
- }
504
-
505
- function objectToString(o) {
506
- return Object.prototype.toString.call(o);
507
- }
508
-
509
- function pad(n) {
510
- return n < 10 ? '0' + n.toString(10) : n.toString(10);
511
- }
512
-
513
- var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']; // 26 Feb 16:19:34
514
-
515
- function timestamp$1() {
516
- var d = new Date();
517
- var time = [pad(d.getHours()), pad(d.getMinutes()), pad(d.getSeconds())].join(':');
518
- return [d.getDate(), months[d.getMonth()], time].join(' ');
519
- } // log is just a thin wrapper to console.log that prepends a timestamp
520
-
521
-
522
- function log() {
523
- console.log('%s - %s', timestamp$1(), format.apply(null, arguments));
524
- }
525
- function _extend(origin, add) {
526
- // Don't do anything if add isn't an object
527
- if (!add || !isObject(add)) return origin;
528
- var keys = Object.keys(add);
529
- var i = keys.length;
530
-
531
- while (i--) {
532
- origin[keys[i]] = add[keys[i]];
533
- }
534
-
535
- return origin;
3
+ function checkForMath(potentialGlobal) {
4
+ // eslint-disable-next-line eqeqeq
5
+ return potentialGlobal && potentialGlobal.Math == Math && potentialGlobal;
536
6
  }
537
-
538
- function hasOwnProperty(obj, prop) {
539
- return Object.prototype.hasOwnProperty.call(obj, prop);
7
+ // https://github.com/zloirock/core-js/issues/86#issuecomment-115759028
8
+ function getGlobal() {
9
+ // eslint-disable-next-line no-undef
10
+ return (checkForMath(typeof globalThis === 'object' && globalThis) ||
11
+ checkForMath(typeof window === 'object' && window) ||
12
+ checkForMath(typeof self === 'object' && self) ||
13
+ checkForMath(typeof global === 'object' && global) ||
14
+ Function('return this')());
540
15
  }
541
16
 
542
- var require$$1 = {
543
- inherits: inherits$1,
544
- _extend: _extend,
545
- log: log,
546
- isBuffer: isBuffer,
547
- isPrimitive: isPrimitive,
548
- isFunction: isFunction,
549
- isError: isError,
550
- isDate: isDate,
551
- isObject: isObject,
552
- isRegExp: isRegExp,
553
- isUndefined: isUndefined,
554
- isSymbol: isSymbol,
555
- isString: isString,
556
- isNumber: isNumber,
557
- isNullOrUndefined: isNullOrUndefined,
558
- isNull: isNull,
559
- isBoolean: isBoolean,
560
- isArray: isArray,
561
- inspect: inspect,
562
- deprecate: deprecate,
563
- format: format,
564
- debuglog: debuglog
565
- };
566
-
567
- var utils = createCommonjsModule(function (module, exports) {
568
- Object.defineProperty(exports, "__esModule", { value: true });
569
- 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;
570
-
571
17
  /**
572
18
  * Normalizes our expected stringified form of a function across versions of node
573
19
  * @param fn - The function to stringify
@@ -575,14 +21,16 @@ exports.deprecate = exports.isObjectLike = exports.isDate = exports.haveBuffer =
575
21
  function normalizedFunctionString(fn) {
576
22
  return fn.toString().replace('function(', 'function (');
577
23
  }
578
- exports.normalizedFunctionString = normalizedFunctionString;
579
- var isReactNative = typeof commonjsGlobal.navigator === 'object' && commonjsGlobal.navigator.product === 'ReactNative';
580
- var insecureWarning = isReactNative
581
- ? 'BSON: For React Native please polyfill crypto.getRandomValues, e.g. using: https://www.npmjs.com/package/react-native-get-random-values.'
582
- : 'BSON: No cryptographic implementation for random bytes present, falling back to a less secure implementation.';
24
+ function isReactNative() {
25
+ var g = getGlobal();
26
+ return typeof g.navigator === 'object' && g.navigator.product === 'ReactNative';
27
+ }
583
28
  var insecureRandomBytes = function insecureRandomBytes(size) {
29
+ var insecureWarning = isReactNative()
30
+ ? 'BSON: For React Native please polyfill crypto.getRandomValues, e.g. using: https://www.npmjs.com/package/react-native-get-random-values.'
31
+ : 'BSON: No cryptographic implementation for random bytes present, falling back to a less secure implementation.';
584
32
  console.warn(insecureWarning);
585
- var result = buffer.Buffer.alloc(size);
33
+ var result = Buffer.alloc(size);
586
34
  for (var i = 0; i < size; ++i)
587
35
  result[i] = Math.floor(Math.random() * 256);
588
36
  return result;
@@ -592,17 +40,17 @@ var detectRandomBytes = function () {
592
40
  // browser crypto implementation(s)
593
41
  var target_1 = window.crypto || window.msCrypto; // allow for IE11
594
42
  if (target_1 && target_1.getRandomValues) {
595
- return function (size) { return target_1.getRandomValues(buffer.Buffer.alloc(size)); };
43
+ return function (size) { return target_1.getRandomValues(Buffer.alloc(size)); };
596
44
  }
597
45
  }
598
- if (typeof commonjsGlobal !== 'undefined' && commonjsGlobal.crypto && commonjsGlobal.crypto.getRandomValues) {
46
+ if (typeof global !== 'undefined' && global.crypto && global.crypto.getRandomValues) {
599
47
  // allow for RN packages such as https://www.npmjs.com/package/react-native-get-random-values to populate global
600
- return function (size) { return commonjsGlobal.crypto.getRandomValues(buffer.Buffer.alloc(size)); };
48
+ return function (size) { return global.crypto.getRandomValues(Buffer.alloc(size)); };
601
49
  }
602
50
  var requiredRandomBytes;
603
51
  try {
604
52
  // eslint-disable-next-line @typescript-eslint/no-var-requires
605
- requiredRandomBytes = require$$0.randomBytes;
53
+ requiredRandomBytes = require('crypto').randomBytes;
606
54
  }
607
55
  catch (e) {
608
56
  // keep the fallback
@@ -610,41 +58,29 @@ var detectRandomBytes = function () {
610
58
  // NOTE: in transpiled cases the above require might return null/undefined
611
59
  return requiredRandomBytes || insecureRandomBytes;
612
60
  };
613
- exports.randomBytes = detectRandomBytes();
61
+ var randomBytes = detectRandomBytes();
614
62
  function isAnyArrayBuffer(value) {
615
63
  return ['[object ArrayBuffer]', '[object SharedArrayBuffer]'].includes(Object.prototype.toString.call(value));
616
64
  }
617
- exports.isAnyArrayBuffer = isAnyArrayBuffer;
618
65
  function isUint8Array(value) {
619
66
  return Object.prototype.toString.call(value) === '[object Uint8Array]';
620
67
  }
621
- exports.isUint8Array = isUint8Array;
622
68
  function isBigInt64Array(value) {
623
69
  return Object.prototype.toString.call(value) === '[object BigInt64Array]';
624
70
  }
625
- exports.isBigInt64Array = isBigInt64Array;
626
71
  function isBigUInt64Array(value) {
627
72
  return Object.prototype.toString.call(value) === '[object BigUint64Array]';
628
73
  }
629
- exports.isBigUInt64Array = isBigUInt64Array;
630
74
  function isRegExp(d) {
631
75
  return Object.prototype.toString.call(d) === '[object RegExp]';
632
76
  }
633
- exports.isRegExp = isRegExp;
634
77
  function isMap(d) {
635
78
  return Object.prototype.toString.call(d) === '[object Map]';
636
79
  }
637
- exports.isMap = isMap;
638
- /** Call to check if your environment has `Buffer` */
639
- function haveBuffer() {
640
- return typeof commonjsGlobal !== 'undefined' && typeof commonjsGlobal.Buffer !== 'undefined';
641
- }
642
- exports.haveBuffer = haveBuffer;
643
80
  // To ensure that 0.4 of node works correctly
644
81
  function isDate(d) {
645
82
  return isObjectLike(d) && Object.prototype.toString.call(d) === '[object Date]';
646
83
  }
647
- exports.isDate = isDate;
648
84
  /**
649
85
  * @internal
650
86
  * this is to solve the `'someKey' in x` problem where x is unknown.
@@ -653,12 +89,7 @@ exports.isDate = isDate;
653
89
  function isObjectLike(candidate) {
654
90
  return typeof candidate === 'object' && candidate !== null;
655
91
  }
656
- exports.isObjectLike = isObjectLike;
657
92
  function deprecate(fn, message) {
658
- if (typeof window === 'undefined' && typeof self === 'undefined') {
659
- // eslint-disable-next-line @typescript-eslint/no-var-requires
660
- return require$$1.deprecate(fn, message);
661
- }
662
93
  var warned = false;
663
94
  function deprecated() {
664
95
  var args = [];
@@ -673,28 +104,6 @@ function deprecate(fn, message) {
673
104
  }
674
105
  return deprecated;
675
106
  }
676
- exports.deprecate = deprecate;
677
- //# sourceMappingURL=utils.js.map
678
- });
679
-
680
- unwrapExports(utils);
681
- utils.deprecate;
682
- utils.isObjectLike;
683
- utils.isDate;
684
- utils.haveBuffer;
685
- utils.isMap;
686
- utils.isRegExp;
687
- utils.isBigUInt64Array;
688
- utils.isBigInt64Array;
689
- utils.isUint8Array;
690
- utils.isAnyArrayBuffer;
691
- utils.randomBytes;
692
- utils.normalizedFunctionString;
693
-
694
- var ensure_buffer = createCommonjsModule(function (module, exports) {
695
- Object.defineProperty(exports, "__esModule", { value: true });
696
- exports.ensureBuffer = void 0;
697
-
698
107
 
699
108
  /**
700
109
  * Makes sure that, if a Uint8Array is passed in, it is wrapped in a Buffer.
@@ -706,38 +115,26 @@ exports.ensureBuffer = void 0;
706
115
  */
707
116
  function ensureBuffer(potentialBuffer) {
708
117
  if (ArrayBuffer.isView(potentialBuffer)) {
709
- return buffer.Buffer.from(potentialBuffer.buffer, potentialBuffer.byteOffset, potentialBuffer.byteLength);
118
+ return Buffer.from(potentialBuffer.buffer, potentialBuffer.byteOffset, potentialBuffer.byteLength);
710
119
  }
711
- if (utils.isAnyArrayBuffer(potentialBuffer)) {
712
- return buffer.Buffer.from(potentialBuffer);
120
+ if (isAnyArrayBuffer(potentialBuffer)) {
121
+ return Buffer.from(potentialBuffer);
713
122
  }
714
123
  throw new TypeError('Must use either Buffer or TypedArray');
715
124
  }
716
- exports.ensureBuffer = ensureBuffer;
717
- //# sourceMappingURL=ensure_buffer.js.map
718
- });
719
-
720
- unwrapExports(ensure_buffer);
721
- ensure_buffer.ensureBuffer;
722
-
723
- var uuid_utils = createCommonjsModule(function (module, exports) {
724
- Object.defineProperty(exports, "__esModule", { value: true });
725
- exports.bufferToUuidHexString = exports.uuidHexStringToBuffer = exports.uuidValidateString = void 0;
726
125
 
727
126
  // Validation regex for v4 uuid (validates with or without dashes)
728
127
  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;
729
128
  var uuidValidateString = function (str) {
730
129
  return typeof str === 'string' && VALIDATION_REGEX.test(str);
731
130
  };
732
- exports.uuidValidateString = uuidValidateString;
733
131
  var uuidHexStringToBuffer = function (hexString) {
734
- if (!exports.uuidValidateString(hexString)) {
132
+ if (!uuidValidateString(hexString)) {
735
133
  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".');
736
134
  }
737
135
  var sanitizedHexString = hexString.replace(/-/g, '');
738
- return buffer.Buffer.from(sanitizedHexString, 'hex');
136
+ return Buffer.from(sanitizedHexString, 'hex');
739
137
  };
740
- exports.uuidHexStringToBuffer = uuidHexStringToBuffer;
741
138
  var bufferToUuidHexString = function (buffer, includeDashes) {
742
139
  if (includeDashes === void 0) { includeDashes = true; }
743
140
  return includeDashes
@@ -752,25 +149,9 @@ var bufferToUuidHexString = function (buffer, includeDashes) {
752
149
  buffer.toString('hex', 10, 16)
753
150
  : buffer.toString('hex');
754
151
  };
755
- exports.bufferToUuidHexString = bufferToUuidHexString;
756
- //# sourceMappingURL=uuid_utils.js.map
757
- });
758
-
759
- unwrapExports(uuid_utils);
760
- uuid_utils.bufferToUuidHexString;
761
- uuid_utils.uuidHexStringToBuffer;
762
- uuid_utils.uuidValidateString;
763
-
764
- var uuid = createCommonjsModule(function (module, exports) {
765
- Object.defineProperty(exports, "__esModule", { value: true });
766
- exports.UUID = void 0;
767
-
768
-
769
-
770
-
771
152
 
772
153
  var BYTE_LENGTH = 16;
773
- var kId = Symbol('id');
154
+ var kId$1 = Symbol('id');
774
155
  /**
775
156
  * A class representation of the BSON UUID type.
776
157
  * @public
@@ -787,14 +168,14 @@ var UUID = /** @class */ (function () {
787
168
  this.id = UUID.generate();
788
169
  }
789
170
  else if (input instanceof UUID) {
790
- this[kId] = buffer.Buffer.from(input.id);
171
+ this[kId$1] = Buffer.from(input.id);
791
172
  this.__id = input.__id;
792
173
  }
793
174
  else if (ArrayBuffer.isView(input) && input.byteLength === BYTE_LENGTH) {
794
- this.id = ensure_buffer.ensureBuffer(input);
175
+ this.id = ensureBuffer(input);
795
176
  }
796
177
  else if (typeof input === 'string') {
797
- this.id = uuid_utils.uuidHexStringToBuffer(input);
178
+ this.id = uuidHexStringToBuffer(input);
798
179
  }
799
180
  else {
800
181
  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).');
@@ -806,12 +187,12 @@ var UUID = /** @class */ (function () {
806
187
  * @readonly
807
188
  */
808
189
  get: function () {
809
- return this[kId];
190
+ return this[kId$1];
810
191
  },
811
192
  set: function (value) {
812
- this[kId] = value;
193
+ this[kId$1] = value;
813
194
  if (UUID.cacheHexString) {
814
- this.__id = uuid_utils.bufferToUuidHexString(value);
195
+ this.__id = bufferToUuidHexString(value);
815
196
  }
816
197
  },
817
198
  enumerable: false,
@@ -829,7 +210,7 @@ var UUID = /** @class */ (function () {
829
210
  if (UUID.cacheHexString && this.__id) {
830
211
  return this.__id;
831
212
  }
832
- var uuidHexString = uuid_utils.bufferToUuidHexString(this.id, includeDashes);
213
+ var uuidHexString = bufferToUuidHexString(this.id, includeDashes);
833
214
  if (UUID.cacheHexString) {
834
215
  this.__id = uuidHexString;
835
216
  }
@@ -837,14 +218,13 @@ var UUID = /** @class */ (function () {
837
218
  };
838
219
  /**
839
220
  * Converts the id into a 36 character (dashes included) hex string, unless a encoding is specified.
840
- * @internal
841
221
  */
842
222
  UUID.prototype.toString = function (encoding) {
843
223
  return encoding ? this.id.toString(encoding) : this.toHexString();
844
224
  };
845
225
  /**
846
- * Converts the id into its JSON string representation. A 36 character (dashes included) hex string in the format: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
847
- * @internal
226
+ * Converts the id into its JSON string representation.
227
+ * A 36 character (dashes included) hex string in the format: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
848
228
  */
849
229
  UUID.prototype.toJSON = function () {
850
230
  return this.toHexString();
@@ -872,18 +252,18 @@ var UUID = /** @class */ (function () {
872
252
  * Creates a Binary instance from the current UUID.
873
253
  */
874
254
  UUID.prototype.toBinary = function () {
875
- return new binary.Binary(this.id, binary.Binary.SUBTYPE_UUID);
255
+ return new Binary(this.id, Binary.SUBTYPE_UUID);
876
256
  };
877
257
  /**
878
258
  * Generates a populated buffer containing a v4 uuid
879
259
  */
880
260
  UUID.generate = function () {
881
- var bytes = utils.randomBytes(BYTE_LENGTH);
261
+ var bytes = randomBytes(BYTE_LENGTH);
882
262
  // Per 4.4, set bits for version and `clock_seq_hi_and_reserved`
883
263
  // Kindly borrowed from https://github.com/uuidjs/uuid/blob/master/src/v4.js
884
264
  bytes[6] = (bytes[6] & 0x0f) | 0x40;
885
265
  bytes[8] = (bytes[8] & 0x3f) | 0x80;
886
- return buffer.Buffer.from(bytes);
266
+ return Buffer.from(bytes);
887
267
  };
888
268
  /**
889
269
  * Checks if a value is a valid bson UUID
@@ -897,9 +277,9 @@ var UUID = /** @class */ (function () {
897
277
  return true;
898
278
  }
899
279
  if (typeof input === 'string') {
900
- return uuid_utils.uuidValidateString(input);
280
+ return uuidValidateString(input);
901
281
  }
902
- if (utils.isUint8Array(input)) {
282
+ if (isUint8Array(input)) {
903
283
  // check for length & uuid version (https://tools.ietf.org/html/rfc4122#section-4.1.3)
904
284
  if (input.length !== BYTE_LENGTH) {
905
285
  return false;
@@ -907,7 +287,7 @@ var UUID = /** @class */ (function () {
907
287
  try {
908
288
  // get this byte as hex: xxxxxxxx-xxxx-XXxx-xxxx-xxxxxxxxxxxx
909
289
  // check first part as uuid version: xxxxxxxx-xxxx-Xxxx-xxxx-xxxxxxxxxxxx
910
- return parseInt(input[6].toString(16)[0], 10) === binary.Binary.SUBTYPE_UUID;
290
+ return parseInt(input[6].toString(16)[0], 10) === Binary.SUBTYPE_UUID;
911
291
  }
912
292
  catch (_a) {
913
293
  return false;
@@ -920,7 +300,7 @@ var UUID = /** @class */ (function () {
920
300
  * @param hexString - 32 or 36 character hex string (dashes excluded/included).
921
301
  */
922
302
  UUID.createFromHexString = function (hexString) {
923
- var buffer = uuid_utils.uuidHexStringToBuffer(hexString);
303
+ var buffer = uuidHexStringToBuffer(hexString);
924
304
  return new UUID(buffer);
925
305
  };
926
306
  /**
@@ -937,20 +317,7 @@ var UUID = /** @class */ (function () {
937
317
  };
938
318
  return UUID;
939
319
  }());
940
- exports.UUID = UUID;
941
320
  Object.defineProperty(UUID.prototype, '_bsontype', { value: 'UUID' });
942
- //# sourceMappingURL=uuid.js.map
943
- });
944
-
945
- unwrapExports(uuid);
946
- uuid.UUID;
947
-
948
- var binary = createCommonjsModule(function (module, exports) {
949
- Object.defineProperty(exports, "__esModule", { value: true });
950
- exports.Binary = void 0;
951
-
952
-
953
-
954
321
 
955
322
  /**
956
323
  * A class representation of the BSON Binary type.
@@ -961,34 +328,34 @@ var Binary = /** @class */ (function () {
961
328
  * @param buffer - a buffer object containing the binary data.
962
329
  * @param subType - the option binary type.
963
330
  */
964
- function Binary(buffer$1, subType) {
331
+ function Binary(buffer, subType) {
965
332
  if (!(this instanceof Binary))
966
- return new Binary(buffer$1, subType);
967
- if (!(buffer$1 == null) &&
968
- !(typeof buffer$1 === 'string') &&
969
- !ArrayBuffer.isView(buffer$1) &&
970
- !(buffer$1 instanceof ArrayBuffer) &&
971
- !Array.isArray(buffer$1)) {
333
+ return new Binary(buffer, subType);
334
+ if (!(buffer == null) &&
335
+ !(typeof buffer === 'string') &&
336
+ !ArrayBuffer.isView(buffer) &&
337
+ !(buffer instanceof ArrayBuffer) &&
338
+ !Array.isArray(buffer)) {
972
339
  throw new TypeError('Binary can only be constructed from string, Buffer, TypedArray, or Array<number>');
973
340
  }
974
341
  this.sub_type = subType !== null && subType !== void 0 ? subType : Binary.BSON_BINARY_SUBTYPE_DEFAULT;
975
- if (buffer$1 == null) {
342
+ if (buffer == null) {
976
343
  // create an empty binary buffer
977
- this.buffer = buffer.Buffer.alloc(Binary.BUFFER_SIZE);
344
+ this.buffer = Buffer.alloc(Binary.BUFFER_SIZE);
978
345
  this.position = 0;
979
346
  }
980
347
  else {
981
- if (typeof buffer$1 === 'string') {
348
+ if (typeof buffer === 'string') {
982
349
  // string
983
- this.buffer = buffer.Buffer.from(buffer$1, 'binary');
350
+ this.buffer = Buffer.from(buffer, 'binary');
984
351
  }
985
- else if (Array.isArray(buffer$1)) {
352
+ else if (Array.isArray(buffer)) {
986
353
  // number[]
987
- this.buffer = buffer.Buffer.from(buffer$1);
354
+ this.buffer = Buffer.from(buffer);
988
355
  }
989
356
  else {
990
357
  // Buffer | TypedArray | ArrayBuffer
991
- this.buffer = ensure_buffer.ensureBuffer(buffer$1);
358
+ this.buffer = ensureBuffer(buffer);
992
359
  }
993
360
  this.position = this.buffer.byteLength;
994
361
  }
@@ -1023,10 +390,10 @@ var Binary = /** @class */ (function () {
1023
390
  this.buffer[this.position++] = decodedByte;
1024
391
  }
1025
392
  else {
1026
- var buffer$1 = buffer.Buffer.alloc(Binary.BUFFER_SIZE + this.buffer.length);
393
+ var buffer = Buffer.alloc(Binary.BUFFER_SIZE + this.buffer.length);
1027
394
  // Combine the two buffers together
1028
- this.buffer.copy(buffer$1, 0, 0, this.buffer.length);
1029
- this.buffer = buffer$1;
395
+ this.buffer.copy(buffer, 0, 0, this.buffer.length);
396
+ this.buffer = buffer;
1030
397
  this.buffer[this.position++] = decodedByte;
1031
398
  }
1032
399
  };
@@ -1040,13 +407,13 @@ var Binary = /** @class */ (function () {
1040
407
  offset = typeof offset === 'number' ? offset : this.position;
1041
408
  // If the buffer is to small let's extend the buffer
1042
409
  if (this.buffer.length < offset + sequence.length) {
1043
- var buffer$1 = buffer.Buffer.alloc(this.buffer.length + sequence.length);
1044
- this.buffer.copy(buffer$1, 0, 0, this.buffer.length);
410
+ var buffer = Buffer.alloc(this.buffer.length + sequence.length);
411
+ this.buffer.copy(buffer, 0, 0, this.buffer.length);
1045
412
  // Assign the new buffer
1046
- this.buffer = buffer$1;
413
+ this.buffer = buffer;
1047
414
  }
1048
415
  if (ArrayBuffer.isView(sequence)) {
1049
- this.buffer.set(ensure_buffer.ensureBuffer(sequence), offset);
416
+ this.buffer.set(ensureBuffer(sequence), offset);
1050
417
  this.position =
1051
418
  offset + sequence.byteLength > this.position ? offset + sequence.length : this.position;
1052
419
  }
@@ -1089,11 +456,9 @@ var Binary = /** @class */ (function () {
1089
456
  Binary.prototype.length = function () {
1090
457
  return this.position;
1091
458
  };
1092
- /** @internal */
1093
459
  Binary.prototype.toJSON = function () {
1094
460
  return this.buffer.toString('base64');
1095
461
  };
1096
- /** @internal */
1097
462
  Binary.prototype.toString = function (format) {
1098
463
  return this.buffer.toString(format);
1099
464
  };
@@ -1115,10 +480,9 @@ var Binary = /** @class */ (function () {
1115
480
  }
1116
481
  };
1117
482
  };
1118
- /** @internal */
1119
483
  Binary.prototype.toUUID = function () {
1120
484
  if (this.sub_type === Binary.SUBTYPE_UUID) {
1121
- return new uuid.UUID(this.buffer.slice(0, this.position));
485
+ return new UUID(this.buffer.slice(0, this.position));
1122
486
  }
1123
487
  throw new Error("Binary sub_type \"" + this.sub_type + "\" is not supported for converting to UUID. Only \"" + Binary.SUBTYPE_UUID + "\" is currently supported.");
1124
488
  };
@@ -1130,18 +494,18 @@ var Binary = /** @class */ (function () {
1130
494
  if ('$binary' in doc) {
1131
495
  if (options.legacy && typeof doc.$binary === 'string' && '$type' in doc) {
1132
496
  type = doc.$type ? parseInt(doc.$type, 16) : 0;
1133
- data = buffer.Buffer.from(doc.$binary, 'base64');
497
+ data = Buffer.from(doc.$binary, 'base64');
1134
498
  }
1135
499
  else {
1136
500
  if (typeof doc.$binary !== 'string') {
1137
501
  type = doc.$binary.subType ? parseInt(doc.$binary.subType, 16) : 0;
1138
- data = buffer.Buffer.from(doc.$binary.base64, 'base64');
502
+ data = Buffer.from(doc.$binary.base64, 'base64');
1139
503
  }
1140
504
  }
1141
505
  }
1142
506
  else if ('$uuid' in doc) {
1143
507
  type = 4;
1144
- data = uuid_utils.uuidHexStringToBuffer(doc.$uuid);
508
+ data = uuidHexStringToBuffer(doc.$uuid);
1145
509
  }
1146
510
  if (!data) {
1147
511
  throw new TypeError("Unexpected Binary Extended JSON format " + JSON.stringify(doc));
@@ -1179,17 +543,8 @@ var Binary = /** @class */ (function () {
1179
543
  Binary.SUBTYPE_USER_DEFINED = 128;
1180
544
  return Binary;
1181
545
  }());
1182
- exports.Binary = Binary;
1183
546
  Object.defineProperty(Binary.prototype, '_bsontype', { value: 'Binary' });
1184
- //# sourceMappingURL=binary.js.map
1185
- });
1186
547
 
1187
- unwrapExports(binary);
1188
- binary.Binary;
1189
-
1190
- var code = createCommonjsModule(function (module, exports) {
1191
- Object.defineProperty(exports, "__esModule", { value: true });
1192
- exports.Code = void 0;
1193
548
  /**
1194
549
  * A class representation of the BSON Code type.
1195
550
  * @public
@@ -1205,7 +560,6 @@ var Code = /** @class */ (function () {
1205
560
  this.code = code;
1206
561
  this.scope = scope;
1207
562
  }
1208
- /** @internal */
1209
563
  Code.prototype.toJSON = function () {
1210
564
  return { code: this.code, scope: this.scope };
1211
565
  };
@@ -1230,23 +584,15 @@ var Code = /** @class */ (function () {
1230
584
  };
1231
585
  return Code;
1232
586
  }());
1233
- exports.Code = Code;
1234
587
  Object.defineProperty(Code.prototype, '_bsontype', { value: 'Code' });
1235
- //# sourceMappingURL=code.js.map
1236
- });
1237
-
1238
- unwrapExports(code);
1239
- code.Code;
1240
-
1241
- var db_ref = createCommonjsModule(function (module, exports) {
1242
- Object.defineProperty(exports, "__esModule", { value: true });
1243
- exports.DBRef = exports.isDBRefLike = void 0;
1244
588
 
1245
589
  /** @internal */
1246
590
  function isDBRefLike(value) {
1247
- return utils.isObjectLike(value) && value['$id'] != null && value['$ref'] != null;
591
+ return (isObjectLike(value) &&
592
+ value.$id != null &&
593
+ typeof value.$ref === 'string' &&
594
+ (value.$db == null || typeof value.$db === 'string'));
1248
595
  }
1249
- exports.isDBRefLike = isDBRefLike;
1250
596
  /**
1251
597
  * A class representation of the BSON DBRef type.
1252
598
  * @public
@@ -1285,7 +631,6 @@ var DBRef = /** @class */ (function () {
1285
631
  enumerable: false,
1286
632
  configurable: true
1287
633
  });
1288
- /** @internal */
1289
634
  DBRef.prototype.toJSON = function () {
1290
635
  var o = Object.assign({
1291
636
  $ref: this.collection,
@@ -1329,18 +674,7 @@ var DBRef = /** @class */ (function () {
1329
674
  };
1330
675
  return DBRef;
1331
676
  }());
1332
- exports.DBRef = DBRef;
1333
677
  Object.defineProperty(DBRef.prototype, '_bsontype', { value: 'DBRef' });
1334
- //# sourceMappingURL=db_ref.js.map
1335
- });
1336
-
1337
- unwrapExports(db_ref);
1338
- db_ref.DBRef;
1339
- db_ref.isDBRefLike;
1340
-
1341
- var long_1 = createCommonjsModule(function (module, exports) {
1342
- Object.defineProperty(exports, "__esModule", { value: true });
1343
- exports.Long = void 0;
1344
678
 
1345
679
  /**
1346
680
  * wasm optimizations, to do native i64 multiplication and divide
@@ -1574,7 +908,7 @@ var Long = /** @class */ (function () {
1574
908
  */
1575
909
  // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types
1576
910
  Long.isLong = function (value) {
1577
- return utils.isObjectLike(value) && value['__isLong__'] === true;
911
+ return isObjectLike(value) && value['__isLong__'] === true;
1578
912
  };
1579
913
  /**
1580
914
  * Converts the specified value to a Long.
@@ -2233,19 +1567,8 @@ var Long = /** @class */ (function () {
2233
1567
  Long.MIN_VALUE = Long.fromBits(0, 0x80000000 | 0, false);
2234
1568
  return Long;
2235
1569
  }());
2236
- exports.Long = Long;
2237
1570
  Object.defineProperty(Long.prototype, '__isLong__', { value: true });
2238
1571
  Object.defineProperty(Long.prototype, '_bsontype', { value: 'Long' });
2239
- //# sourceMappingURL=long.js.map
2240
- });
2241
-
2242
- unwrapExports(long_1);
2243
- long_1.Long;
2244
-
2245
- var decimal128 = createCommonjsModule(function (module, exports) {
2246
- Object.defineProperty(exports, "__esModule", { value: true });
2247
- exports.Decimal128 = void 0;
2248
-
2249
1572
 
2250
1573
  var PARSE_STRING_REGEXP = /^(\+|-)?(\d+|(\d*\.\d*))?(E|e)?([-+])?(\d+)?$/;
2251
1574
  var PARSE_INF_REGEXP = /^(\+|-)?(Infinity|inf)$/i;
@@ -2256,59 +1579,14 @@ var EXPONENT_BIAS = 6176;
2256
1579
  var MAX_DIGITS = 34;
2257
1580
  // Nan value bits as 32 bit values (due to lack of longs)
2258
1581
  var NAN_BUFFER = [
2259
- 0x7c,
2260
- 0x00,
2261
- 0x00,
2262
- 0x00,
2263
- 0x00,
2264
- 0x00,
2265
- 0x00,
2266
- 0x00,
2267
- 0x00,
2268
- 0x00,
2269
- 0x00,
2270
- 0x00,
2271
- 0x00,
2272
- 0x00,
2273
- 0x00,
2274
- 0x00
1582
+ 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
2275
1583
  ].reverse();
2276
1584
  // Infinity value bits 32 bit values (due to lack of longs)
2277
1585
  var INF_NEGATIVE_BUFFER = [
2278
- 0xf8,
2279
- 0x00,
2280
- 0x00,
2281
- 0x00,
2282
- 0x00,
2283
- 0x00,
2284
- 0x00,
2285
- 0x00,
2286
- 0x00,
2287
- 0x00,
2288
- 0x00,
2289
- 0x00,
2290
- 0x00,
2291
- 0x00,
2292
- 0x00,
2293
- 0x00
1586
+ 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
2294
1587
  ].reverse();
2295
1588
  var INF_POSITIVE_BUFFER = [
2296
- 0x78,
2297
- 0x00,
2298
- 0x00,
2299
- 0x00,
2300
- 0x00,
2301
- 0x00,
2302
- 0x00,
2303
- 0x00,
2304
- 0x00,
2305
- 0x00,
2306
- 0x00,
2307
- 0x00,
2308
- 0x00,
2309
- 0x00,
2310
- 0x00,
2311
- 0x00
1589
+ 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
2312
1590
  ].reverse();
2313
1591
  var EXPONENT_REGEX = /^([-+])?(\d+)?$/;
2314
1592
  // Extract least significant 5 bits
@@ -2325,8 +1603,8 @@ function isDigit(value) {
2325
1603
  }
2326
1604
  // Divide two uint128 values
2327
1605
  function divideu128(value) {
2328
- var DIVISOR = long_1.Long.fromNumber(1000 * 1000 * 1000);
2329
- var _rem = long_1.Long.fromNumber(0);
1606
+ var DIVISOR = Long.fromNumber(1000 * 1000 * 1000);
1607
+ var _rem = Long.fromNumber(0);
2330
1608
  if (!value.parts[0] && !value.parts[1] && !value.parts[2] && !value.parts[3]) {
2331
1609
  return { quotient: value, rem: _rem };
2332
1610
  }
@@ -2334,7 +1612,7 @@ function divideu128(value) {
2334
1612
  // Adjust remainder to match value of next dividend
2335
1613
  _rem = _rem.shiftLeft(32);
2336
1614
  // Add the divided to _rem
2337
- _rem = _rem.add(new long_1.Long(value.parts[i], 0));
1615
+ _rem = _rem.add(new Long(value.parts[i], 0));
2338
1616
  value.parts[i] = _rem.div(DIVISOR).low;
2339
1617
  _rem = _rem.modulo(DIVISOR);
2340
1618
  }
@@ -2343,22 +1621,22 @@ function divideu128(value) {
2343
1621
  // Multiply two Long values and return the 128 bit value
2344
1622
  function multiply64x2(left, right) {
2345
1623
  if (!left && !right) {
2346
- return { high: long_1.Long.fromNumber(0), low: long_1.Long.fromNumber(0) };
1624
+ return { high: Long.fromNumber(0), low: Long.fromNumber(0) };
2347
1625
  }
2348
1626
  var leftHigh = left.shiftRightUnsigned(32);
2349
- var leftLow = new long_1.Long(left.getLowBits(), 0);
1627
+ var leftLow = new Long(left.getLowBits(), 0);
2350
1628
  var rightHigh = right.shiftRightUnsigned(32);
2351
- var rightLow = new long_1.Long(right.getLowBits(), 0);
1629
+ var rightLow = new Long(right.getLowBits(), 0);
2352
1630
  var productHigh = leftHigh.multiply(rightHigh);
2353
1631
  var productMid = leftHigh.multiply(rightLow);
2354
1632
  var productMid2 = leftLow.multiply(rightHigh);
2355
1633
  var productLow = leftLow.multiply(rightLow);
2356
1634
  productHigh = productHigh.add(productMid.shiftRightUnsigned(32));
2357
- productMid = new long_1.Long(productMid.getLowBits(), 0)
1635
+ productMid = new Long(productMid.getLowBits(), 0)
2358
1636
  .add(productMid2)
2359
1637
  .add(productLow.shiftRightUnsigned(32));
2360
1638
  productHigh = productHigh.add(productMid.shiftRightUnsigned(32));
2361
- productLow = productMid.shiftLeft(32).add(new long_1.Long(productLow.getLowBits(), 0));
1639
+ productLow = productMid.shiftLeft(32).add(new Long(productLow.getLowBits(), 0));
2362
1640
  // Return the 128 bit result
2363
1641
  return { high: productHigh, low: productLow };
2364
1642
  }
@@ -2435,9 +1713,9 @@ var Decimal128 = /** @class */ (function () {
2435
1713
  // loop index over array
2436
1714
  var i = 0;
2437
1715
  // The high 17 digits of the significand
2438
- var significandHigh = new long_1.Long(0, 0);
1716
+ var significandHigh = new Long(0, 0);
2439
1717
  // The low 17 digits of the significand
2440
- var significandLow = new long_1.Long(0, 0);
1718
+ var significandLow = new Long(0, 0);
2441
1719
  // The biased exponent
2442
1720
  var biasedExponent = 0;
2443
1721
  // Read index
@@ -2482,10 +1760,10 @@ var Decimal128 = /** @class */ (function () {
2482
1760
  // Check if user passed Infinity or NaN
2483
1761
  if (!isDigit(representation[index]) && representation[index] !== '.') {
2484
1762
  if (representation[index] === 'i' || representation[index] === 'I') {
2485
- return new Decimal128(buffer.Buffer.from(isNegative ? INF_NEGATIVE_BUFFER : INF_POSITIVE_BUFFER));
1763
+ return new Decimal128(Buffer.from(isNegative ? INF_NEGATIVE_BUFFER : INF_POSITIVE_BUFFER));
2486
1764
  }
2487
1765
  else if (representation[index] === 'N') {
2488
- return new Decimal128(buffer.Buffer.from(NAN_BUFFER));
1766
+ return new Decimal128(Buffer.from(NAN_BUFFER));
2489
1767
  }
2490
1768
  }
2491
1769
  // Read all the digits
@@ -2523,7 +1801,7 @@ var Decimal128 = /** @class */ (function () {
2523
1801
  var match = representation.substr(++index).match(EXPONENT_REGEX);
2524
1802
  // No digits read
2525
1803
  if (!match || !match[2])
2526
- return new Decimal128(buffer.Buffer.from(NAN_BUFFER));
1804
+ return new Decimal128(Buffer.from(NAN_BUFFER));
2527
1805
  // Get exponent
2528
1806
  exponent = parseInt(match[0], 10);
2529
1807
  // Adjust the index
@@ -2531,7 +1809,7 @@ var Decimal128 = /** @class */ (function () {
2531
1809
  }
2532
1810
  // Return not a number
2533
1811
  if (representation[index])
2534
- return new Decimal128(buffer.Buffer.from(NAN_BUFFER));
1812
+ return new Decimal128(Buffer.from(NAN_BUFFER));
2535
1813
  // Done reading input
2536
1814
  // Find first non-zero digit in digits
2537
1815
  firstDigit = 0;
@@ -2547,7 +1825,7 @@ var Decimal128 = /** @class */ (function () {
2547
1825
  lastDigit = nDigitsStored - 1;
2548
1826
  significantDigits = nDigits;
2549
1827
  if (significantDigits !== 1) {
2550
- while (representation[firstNonZero + significantDigits - 1] === '0') {
1828
+ while (digits[firstNonZero + significantDigits - 1] === 0) {
2551
1829
  significantDigits = significantDigits - 1;
2552
1830
  }
2553
1831
  }
@@ -2647,7 +1925,7 @@ var Decimal128 = /** @class */ (function () {
2647
1925
  digits[dIdx] = 1;
2648
1926
  }
2649
1927
  else {
2650
- return new Decimal128(buffer.Buffer.from(isNegative ? INF_NEGATIVE_BUFFER : INF_POSITIVE_BUFFER));
1928
+ return new Decimal128(Buffer.from(isNegative ? INF_NEGATIVE_BUFFER : INF_POSITIVE_BUFFER));
2651
1929
  }
2652
1930
  }
2653
1931
  }
@@ -2656,87 +1934,87 @@ var Decimal128 = /** @class */ (function () {
2656
1934
  }
2657
1935
  // Encode significand
2658
1936
  // The high 17 digits of the significand
2659
- significandHigh = long_1.Long.fromNumber(0);
1937
+ significandHigh = Long.fromNumber(0);
2660
1938
  // The low 17 digits of the significand
2661
- significandLow = long_1.Long.fromNumber(0);
1939
+ significandLow = Long.fromNumber(0);
2662
1940
  // read a zero
2663
1941
  if (significantDigits === 0) {
2664
- significandHigh = long_1.Long.fromNumber(0);
2665
- significandLow = long_1.Long.fromNumber(0);
1942
+ significandHigh = Long.fromNumber(0);
1943
+ significandLow = Long.fromNumber(0);
2666
1944
  }
2667
1945
  else if (lastDigit - firstDigit < 17) {
2668
1946
  var dIdx = firstDigit;
2669
- significandLow = long_1.Long.fromNumber(digits[dIdx++]);
2670
- significandHigh = new long_1.Long(0, 0);
1947
+ significandLow = Long.fromNumber(digits[dIdx++]);
1948
+ significandHigh = new Long(0, 0);
2671
1949
  for (; dIdx <= lastDigit; dIdx++) {
2672
- significandLow = significandLow.multiply(long_1.Long.fromNumber(10));
2673
- significandLow = significandLow.add(long_1.Long.fromNumber(digits[dIdx]));
1950
+ significandLow = significandLow.multiply(Long.fromNumber(10));
1951
+ significandLow = significandLow.add(Long.fromNumber(digits[dIdx]));
2674
1952
  }
2675
1953
  }
2676
1954
  else {
2677
1955
  var dIdx = firstDigit;
2678
- significandHigh = long_1.Long.fromNumber(digits[dIdx++]);
1956
+ significandHigh = Long.fromNumber(digits[dIdx++]);
2679
1957
  for (; dIdx <= lastDigit - 17; dIdx++) {
2680
- significandHigh = significandHigh.multiply(long_1.Long.fromNumber(10));
2681
- significandHigh = significandHigh.add(long_1.Long.fromNumber(digits[dIdx]));
1958
+ significandHigh = significandHigh.multiply(Long.fromNumber(10));
1959
+ significandHigh = significandHigh.add(Long.fromNumber(digits[dIdx]));
2682
1960
  }
2683
- significandLow = long_1.Long.fromNumber(digits[dIdx++]);
1961
+ significandLow = Long.fromNumber(digits[dIdx++]);
2684
1962
  for (; dIdx <= lastDigit; dIdx++) {
2685
- significandLow = significandLow.multiply(long_1.Long.fromNumber(10));
2686
- significandLow = significandLow.add(long_1.Long.fromNumber(digits[dIdx]));
1963
+ significandLow = significandLow.multiply(Long.fromNumber(10));
1964
+ significandLow = significandLow.add(Long.fromNumber(digits[dIdx]));
2687
1965
  }
2688
1966
  }
2689
- var significand = multiply64x2(significandHigh, long_1.Long.fromString('100000000000000000'));
1967
+ var significand = multiply64x2(significandHigh, Long.fromString('100000000000000000'));
2690
1968
  significand.low = significand.low.add(significandLow);
2691
1969
  if (lessThan(significand.low, significandLow)) {
2692
- significand.high = significand.high.add(long_1.Long.fromNumber(1));
1970
+ significand.high = significand.high.add(Long.fromNumber(1));
2693
1971
  }
2694
1972
  // Biased exponent
2695
1973
  biasedExponent = exponent + EXPONENT_BIAS;
2696
- var dec = { low: long_1.Long.fromNumber(0), high: long_1.Long.fromNumber(0) };
1974
+ var dec = { low: Long.fromNumber(0), high: Long.fromNumber(0) };
2697
1975
  // Encode combination, exponent, and significand.
2698
- if (significand.high.shiftRightUnsigned(49).and(long_1.Long.fromNumber(1)).equals(long_1.Long.fromNumber(1))) {
1976
+ if (significand.high.shiftRightUnsigned(49).and(Long.fromNumber(1)).equals(Long.fromNumber(1))) {
2699
1977
  // Encode '11' into bits 1 to 3
2700
- dec.high = dec.high.or(long_1.Long.fromNumber(0x3).shiftLeft(61));
2701
- dec.high = dec.high.or(long_1.Long.fromNumber(biasedExponent).and(long_1.Long.fromNumber(0x3fff).shiftLeft(47)));
2702
- dec.high = dec.high.or(significand.high.and(long_1.Long.fromNumber(0x7fffffffffff)));
1978
+ dec.high = dec.high.or(Long.fromNumber(0x3).shiftLeft(61));
1979
+ dec.high = dec.high.or(Long.fromNumber(biasedExponent).and(Long.fromNumber(0x3fff).shiftLeft(47)));
1980
+ dec.high = dec.high.or(significand.high.and(Long.fromNumber(0x7fffffffffff)));
2703
1981
  }
2704
1982
  else {
2705
- dec.high = dec.high.or(long_1.Long.fromNumber(biasedExponent & 0x3fff).shiftLeft(49));
2706
- dec.high = dec.high.or(significand.high.and(long_1.Long.fromNumber(0x1ffffffffffff)));
1983
+ dec.high = dec.high.or(Long.fromNumber(biasedExponent & 0x3fff).shiftLeft(49));
1984
+ dec.high = dec.high.or(significand.high.and(Long.fromNumber(0x1ffffffffffff)));
2707
1985
  }
2708
1986
  dec.low = significand.low;
2709
1987
  // Encode sign
2710
1988
  if (isNegative) {
2711
- dec.high = dec.high.or(long_1.Long.fromString('9223372036854775808'));
1989
+ dec.high = dec.high.or(Long.fromString('9223372036854775808'));
2712
1990
  }
2713
1991
  // Encode into a buffer
2714
- var buffer$1 = buffer.Buffer.alloc(16);
1992
+ var buffer = Buffer.alloc(16);
2715
1993
  index = 0;
2716
1994
  // Encode the low 64 bits of the decimal
2717
1995
  // Encode low bits
2718
- buffer$1[index++] = dec.low.low & 0xff;
2719
- buffer$1[index++] = (dec.low.low >> 8) & 0xff;
2720
- buffer$1[index++] = (dec.low.low >> 16) & 0xff;
2721
- buffer$1[index++] = (dec.low.low >> 24) & 0xff;
1996
+ buffer[index++] = dec.low.low & 0xff;
1997
+ buffer[index++] = (dec.low.low >> 8) & 0xff;
1998
+ buffer[index++] = (dec.low.low >> 16) & 0xff;
1999
+ buffer[index++] = (dec.low.low >> 24) & 0xff;
2722
2000
  // Encode high bits
2723
- buffer$1[index++] = dec.low.high & 0xff;
2724
- buffer$1[index++] = (dec.low.high >> 8) & 0xff;
2725
- buffer$1[index++] = (dec.low.high >> 16) & 0xff;
2726
- buffer$1[index++] = (dec.low.high >> 24) & 0xff;
2001
+ buffer[index++] = dec.low.high & 0xff;
2002
+ buffer[index++] = (dec.low.high >> 8) & 0xff;
2003
+ buffer[index++] = (dec.low.high >> 16) & 0xff;
2004
+ buffer[index++] = (dec.low.high >> 24) & 0xff;
2727
2005
  // Encode the high 64 bits of the decimal
2728
2006
  // Encode low bits
2729
- buffer$1[index++] = dec.high.low & 0xff;
2730
- buffer$1[index++] = (dec.high.low >> 8) & 0xff;
2731
- buffer$1[index++] = (dec.high.low >> 16) & 0xff;
2732
- buffer$1[index++] = (dec.high.low >> 24) & 0xff;
2007
+ buffer[index++] = dec.high.low & 0xff;
2008
+ buffer[index++] = (dec.high.low >> 8) & 0xff;
2009
+ buffer[index++] = (dec.high.low >> 16) & 0xff;
2010
+ buffer[index++] = (dec.high.low >> 24) & 0xff;
2733
2011
  // Encode high bits
2734
- buffer$1[index++] = dec.high.high & 0xff;
2735
- buffer$1[index++] = (dec.high.high >> 8) & 0xff;
2736
- buffer$1[index++] = (dec.high.high >> 16) & 0xff;
2737
- buffer$1[index++] = (dec.high.high >> 24) & 0xff;
2012
+ buffer[index++] = dec.high.high & 0xff;
2013
+ buffer[index++] = (dec.high.high >> 8) & 0xff;
2014
+ buffer[index++] = (dec.high.high >> 16) & 0xff;
2015
+ buffer[index++] = (dec.high.high >> 24) & 0xff;
2738
2016
  // Return the new Decimal128
2739
- return new Decimal128(buffer$1);
2017
+ return new Decimal128(buffer);
2740
2018
  };
2741
2019
  /** Create a string representation of the raw Decimal128 value */
2742
2020
  Decimal128.prototype.toString = function () {
@@ -2780,10 +2058,10 @@ var Decimal128 = /** @class */ (function () {
2780
2058
  index = 0;
2781
2059
  // Create the state of the decimal
2782
2060
  var dec = {
2783
- low: new long_1.Long(low, midl),
2784
- high: new long_1.Long(midh, high)
2061
+ low: new Long(low, midl),
2062
+ high: new Long(midh, high)
2785
2063
  };
2786
- if (dec.high.lessThan(long_1.Long.ZERO)) {
2064
+ if (dec.high.lessThan(Long.ZERO)) {
2787
2065
  string.push('-');
2788
2066
  }
2789
2067
  // Decode combination field and exponent
@@ -2944,17 +2222,8 @@ var Decimal128 = /** @class */ (function () {
2944
2222
  };
2945
2223
  return Decimal128;
2946
2224
  }());
2947
- exports.Decimal128 = Decimal128;
2948
2225
  Object.defineProperty(Decimal128.prototype, '_bsontype', { value: 'Decimal128' });
2949
- //# sourceMappingURL=decimal128.js.map
2950
- });
2951
2226
 
2952
- unwrapExports(decimal128);
2953
- decimal128.Decimal128;
2954
-
2955
- var double_1 = createCommonjsModule(function (module, exports) {
2956
- Object.defineProperty(exports, "__esModule", { value: true });
2957
- exports.Double = void 0;
2958
2227
  /**
2959
2228
  * A class representation of the BSON Double type.
2960
2229
  * @public
@@ -2981,10 +2250,12 @@ var Double = /** @class */ (function () {
2981
2250
  Double.prototype.valueOf = function () {
2982
2251
  return this.value;
2983
2252
  };
2984
- /** @internal */
2985
2253
  Double.prototype.toJSON = function () {
2986
2254
  return this.value;
2987
2255
  };
2256
+ Double.prototype.toString = function (radix) {
2257
+ return this.value.toString(radix);
2258
+ };
2988
2259
  /** @internal */
2989
2260
  Double.prototype.toExtendedJSON = function (options) {
2990
2261
  if (options && (options.legacy || (options.relaxed && isFinite(this.value)))) {
@@ -3022,17 +2293,8 @@ var Double = /** @class */ (function () {
3022
2293
  };
3023
2294
  return Double;
3024
2295
  }());
3025
- exports.Double = Double;
3026
2296
  Object.defineProperty(Double.prototype, '_bsontype', { value: 'Double' });
3027
- //# sourceMappingURL=double.js.map
3028
- });
3029
2297
 
3030
- unwrapExports(double_1);
3031
- double_1.Double;
3032
-
3033
- var int_32 = createCommonjsModule(function (module, exports) {
3034
- Object.defineProperty(exports, "__esModule", { value: true });
3035
- exports.Int32 = void 0;
3036
2298
  /**
3037
2299
  * A class representation of a BSON Int32 type.
3038
2300
  * @public
@@ -3059,7 +2321,9 @@ var Int32 = /** @class */ (function () {
3059
2321
  Int32.prototype.valueOf = function () {
3060
2322
  return this.value;
3061
2323
  };
3062
- /** @internal */
2324
+ Int32.prototype.toString = function (radix) {
2325
+ return this.value.toString(radix);
2326
+ };
3063
2327
  Int32.prototype.toJSON = function () {
3064
2328
  return this.value;
3065
2329
  };
@@ -3082,17 +2346,8 @@ var Int32 = /** @class */ (function () {
3082
2346
  };
3083
2347
  return Int32;
3084
2348
  }());
3085
- exports.Int32 = Int32;
3086
2349
  Object.defineProperty(Int32.prototype, '_bsontype', { value: 'Int32' });
3087
- //# sourceMappingURL=int_32.js.map
3088
- });
3089
2350
 
3090
- unwrapExports(int_32);
3091
- int_32.Int32;
3092
-
3093
- var max_key = createCommonjsModule(function (module, exports) {
3094
- Object.defineProperty(exports, "__esModule", { value: true });
3095
- exports.MaxKey = void 0;
3096
2351
  /**
3097
2352
  * A class representation of the BSON MaxKey type.
3098
2353
  * @public
@@ -3119,17 +2374,8 @@ var MaxKey = /** @class */ (function () {
3119
2374
  };
3120
2375
  return MaxKey;
3121
2376
  }());
3122
- exports.MaxKey = MaxKey;
3123
2377
  Object.defineProperty(MaxKey.prototype, '_bsontype', { value: 'MaxKey' });
3124
- //# sourceMappingURL=max_key.js.map
3125
- });
3126
2378
 
3127
- unwrapExports(max_key);
3128
- max_key.MaxKey;
3129
-
3130
- var min_key = createCommonjsModule(function (module, exports) {
3131
- Object.defineProperty(exports, "__esModule", { value: true });
3132
- exports.MinKey = void 0;
3133
2379
  /**
3134
2380
  * A class representation of the BSON MinKey type.
3135
2381
  * @public
@@ -3156,19 +2402,7 @@ var MinKey = /** @class */ (function () {
3156
2402
  };
3157
2403
  return MinKey;
3158
2404
  }());
3159
- exports.MinKey = MinKey;
3160
2405
  Object.defineProperty(MinKey.prototype, '_bsontype', { value: 'MinKey' });
3161
- //# sourceMappingURL=min_key.js.map
3162
- });
3163
-
3164
- unwrapExports(min_key);
3165
- min_key.MinKey;
3166
-
3167
- var objectid = createCommonjsModule(function (module, exports) {
3168
- Object.defineProperty(exports, "__esModule", { value: true });
3169
- exports.ObjectId = void 0;
3170
-
3171
-
3172
2406
 
3173
2407
  // Regular expression that checks for hex value
3174
2408
  var checkForHexRegExp = new RegExp('^[0-9a-fA-F]{24}$');
@@ -3195,10 +2429,10 @@ var ObjectId = /** @class */ (function () {
3195
2429
  }
3196
2430
  if (typeof id === 'object' && id && 'id' in id) {
3197
2431
  if ('toHexString' in id && typeof id.toHexString === 'function') {
3198
- this[kId] = buffer.Buffer.from(id.toHexString(), 'hex');
2432
+ this[kId] = Buffer.from(id.toHexString(), 'hex');
3199
2433
  }
3200
2434
  else {
3201
- this[kId] = typeof id.id === 'string' ? buffer.Buffer.from(id.id) : id.id;
2435
+ this[kId] = typeof id.id === 'string' ? Buffer.from(id.id) : id.id;
3202
2436
  }
3203
2437
  }
3204
2438
  // The most common use case (blank id, new objectId instance)
@@ -3211,17 +2445,17 @@ var ObjectId = /** @class */ (function () {
3211
2445
  }
3212
2446
  }
3213
2447
  if (ArrayBuffer.isView(id) && id.byteLength === 12) {
3214
- this[kId] = ensure_buffer.ensureBuffer(id);
2448
+ this[kId] = ensureBuffer(id);
3215
2449
  }
3216
2450
  if (typeof id === 'string') {
3217
2451
  if (id.length === 12) {
3218
- var bytes = buffer.Buffer.from(id);
2452
+ var bytes = Buffer.from(id);
3219
2453
  if (bytes.byteLength === 12) {
3220
2454
  this[kId] = bytes;
3221
2455
  }
3222
2456
  }
3223
2457
  else if (id.length === 24 && checkForHexRegExp.test(id)) {
3224
- this[kId] = buffer.Buffer.from(id, 'hex');
2458
+ this[kId] = Buffer.from(id, 'hex');
3225
2459
  }
3226
2460
  else {
3227
2461
  throw new TypeError('Argument passed in must be a Buffer or string of 12 bytes or a string of 24 hex characters');
@@ -3293,41 +2527,37 @@ var ObjectId = /** @class */ (function () {
3293
2527
  time = ~~(Date.now() / 1000);
3294
2528
  }
3295
2529
  var inc = ObjectId.getInc();
3296
- var buffer$1 = buffer.Buffer.alloc(12);
2530
+ var buffer = Buffer.alloc(12);
3297
2531
  // 4-byte timestamp
3298
- buffer$1.writeUInt32BE(time, 0);
2532
+ buffer.writeUInt32BE(time, 0);
3299
2533
  // set PROCESS_UNIQUE if yet not initialized
3300
2534
  if (PROCESS_UNIQUE === null) {
3301
- PROCESS_UNIQUE = utils.randomBytes(5);
2535
+ PROCESS_UNIQUE = randomBytes(5);
3302
2536
  }
3303
2537
  // 5-byte process unique
3304
- buffer$1[4] = PROCESS_UNIQUE[0];
3305
- buffer$1[5] = PROCESS_UNIQUE[1];
3306
- buffer$1[6] = PROCESS_UNIQUE[2];
3307
- buffer$1[7] = PROCESS_UNIQUE[3];
3308
- buffer$1[8] = PROCESS_UNIQUE[4];
2538
+ buffer[4] = PROCESS_UNIQUE[0];
2539
+ buffer[5] = PROCESS_UNIQUE[1];
2540
+ buffer[6] = PROCESS_UNIQUE[2];
2541
+ buffer[7] = PROCESS_UNIQUE[3];
2542
+ buffer[8] = PROCESS_UNIQUE[4];
3309
2543
  // 3-byte counter
3310
- buffer$1[11] = inc & 0xff;
3311
- buffer$1[10] = (inc >> 8) & 0xff;
3312
- buffer$1[9] = (inc >> 16) & 0xff;
3313
- return buffer$1;
2544
+ buffer[11] = inc & 0xff;
2545
+ buffer[10] = (inc >> 8) & 0xff;
2546
+ buffer[9] = (inc >> 16) & 0xff;
2547
+ return buffer;
3314
2548
  };
3315
2549
  /**
3316
2550
  * Converts the id into a 24 character hex string for printing
3317
2551
  *
3318
2552
  * @param format - The Buffer toString format parameter.
3319
- * @internal
3320
2553
  */
3321
2554
  ObjectId.prototype.toString = function (format) {
3322
2555
  // Is the id a buffer then use the buffer toString method to return the format
3323
2556
  if (format)
3324
2557
  return this.id.toString(format);
3325
- return this.toHexString();
3326
- };
3327
- /**
3328
- * Converts to its JSON the 24 character hex string representation.
3329
- * @internal
3330
- */
2558
+ return this.toHexString();
2559
+ };
2560
+ /** Converts to its JSON the 24 character hex string representation. */
3331
2561
  ObjectId.prototype.toJSON = function () {
3332
2562
  return this.toHexString();
3333
2563
  };
@@ -3346,14 +2576,14 @@ var ObjectId = /** @class */ (function () {
3346
2576
  if (typeof otherId === 'string' &&
3347
2577
  ObjectId.isValid(otherId) &&
3348
2578
  otherId.length === 12 &&
3349
- utils.isUint8Array(this.id)) {
3350
- return otherId === buffer.Buffer.prototype.toString.call(this.id, 'latin1');
2579
+ isUint8Array(this.id)) {
2580
+ return otherId === Buffer.prototype.toString.call(this.id, 'latin1');
3351
2581
  }
3352
2582
  if (typeof otherId === 'string' && ObjectId.isValid(otherId) && otherId.length === 24) {
3353
2583
  return otherId.toLowerCase() === this.toHexString();
3354
2584
  }
3355
2585
  if (typeof otherId === 'string' && ObjectId.isValid(otherId) && otherId.length === 12) {
3356
- return buffer.Buffer.from(otherId).equals(this.id);
2586
+ return Buffer.from(otherId).equals(this.id);
3357
2587
  }
3358
2588
  if (typeof otherId === 'object' &&
3359
2589
  'toHexString' in otherId &&
@@ -3379,11 +2609,11 @@ var ObjectId = /** @class */ (function () {
3379
2609
  * @param time - an integer number representing a number of seconds.
3380
2610
  */
3381
2611
  ObjectId.createFromTime = function (time) {
3382
- var buffer$1 = buffer.Buffer.from([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]);
2612
+ var buffer = Buffer.from([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]);
3383
2613
  // Encode time into first 4 bytes
3384
- buffer$1.writeUInt32BE(time, 0);
2614
+ buffer.writeUInt32BE(time, 0);
3385
2615
  // Return the new objectId
3386
- return new ObjectId(buffer$1);
2616
+ return new ObjectId(buffer);
3387
2617
  };
3388
2618
  /**
3389
2619
  * Creates an ObjectId from a hex string representation of an ObjectId.
@@ -3395,7 +2625,7 @@ var ObjectId = /** @class */ (function () {
3395
2625
  if (typeof hexString === 'undefined' || (hexString != null && hexString.length !== 24)) {
3396
2626
  throw new TypeError('Argument passed in must be a single String of 12 bytes or a string of 24 hex characters');
3397
2627
  }
3398
- return new ObjectId(buffer.Buffer.from(hexString, 'hex'));
2628
+ return new ObjectId(Buffer.from(hexString, 'hex'));
3399
2629
  };
3400
2630
  /**
3401
2631
  * Checks if a value is a valid bson ObjectId
@@ -3414,7 +2644,7 @@ var ObjectId = /** @class */ (function () {
3414
2644
  if (id instanceof ObjectId) {
3415
2645
  return true;
3416
2646
  }
3417
- if (utils.isUint8Array(id) && id.length === 12) {
2647
+ if (isUint8Array(id) && id.length === 12) {
3418
2648
  return true;
3419
2649
  }
3420
2650
  // Duck-Typing detection of ObjectId like objects
@@ -3452,30 +2682,21 @@ var ObjectId = /** @class */ (function () {
3452
2682
  ObjectId.index = ~~(Math.random() * 0xffffff);
3453
2683
  return ObjectId;
3454
2684
  }());
3455
- exports.ObjectId = ObjectId;
3456
2685
  // Deprecated methods
3457
2686
  Object.defineProperty(ObjectId.prototype, 'generate', {
3458
- value: utils.deprecate(function (time) { return ObjectId.generate(time); }, 'Please use the static `ObjectId.generate(time)` instead')
2687
+ value: deprecate(function (time) { return ObjectId.generate(time); }, 'Please use the static `ObjectId.generate(time)` instead')
3459
2688
  });
3460
2689
  Object.defineProperty(ObjectId.prototype, 'getInc', {
3461
- value: utils.deprecate(function () { return ObjectId.getInc(); }, 'Please use the static `ObjectId.getInc()` instead')
2690
+ value: deprecate(function () { return ObjectId.getInc(); }, 'Please use the static `ObjectId.getInc()` instead')
3462
2691
  });
3463
2692
  Object.defineProperty(ObjectId.prototype, 'get_inc', {
3464
- value: utils.deprecate(function () { return ObjectId.getInc(); }, 'Please use the static `ObjectId.getInc()` instead')
2693
+ value: deprecate(function () { return ObjectId.getInc(); }, 'Please use the static `ObjectId.getInc()` instead')
3465
2694
  });
3466
2695
  Object.defineProperty(ObjectId, 'get_inc', {
3467
- value: utils.deprecate(function () { return ObjectId.getInc(); }, 'Please use the static `ObjectId.getInc()` instead')
2696
+ value: deprecate(function () { return ObjectId.getInc(); }, 'Please use the static `ObjectId.getInc()` instead')
3468
2697
  });
3469
2698
  Object.defineProperty(ObjectId.prototype, '_bsontype', { value: 'ObjectID' });
3470
- //# sourceMappingURL=objectid.js.map
3471
- });
3472
-
3473
- unwrapExports(objectid);
3474
- objectid.ObjectId;
3475
2699
 
3476
- var regexp = createCommonjsModule(function (module, exports) {
3477
- Object.defineProperty(exports, "__esModule", { value: true });
3478
- exports.BSONRegExp = void 0;
3479
2700
  function alphabetize(str) {
3480
2701
  return str.split('').sort().join('');
3481
2702
  }
@@ -3492,9 +2713,7 @@ var BSONRegExp = /** @class */ (function () {
3492
2713
  if (!(this instanceof BSONRegExp))
3493
2714
  return new BSONRegExp(pattern, options);
3494
2715
  this.pattern = pattern;
3495
- this.options = options !== null && options !== void 0 ? options : '';
3496
- // Execute
3497
- alphabetize(this.options);
2716
+ this.options = alphabetize(options !== null && options !== void 0 ? options : '');
3498
2717
  // Validate options
3499
2718
  for (var i = 0; i < this.options.length; i++) {
3500
2719
  if (!(this.options[i] === 'i' ||
@@ -3538,17 +2757,8 @@ var BSONRegExp = /** @class */ (function () {
3538
2757
  };
3539
2758
  return BSONRegExp;
3540
2759
  }());
3541
- exports.BSONRegExp = BSONRegExp;
3542
2760
  Object.defineProperty(BSONRegExp.prototype, '_bsontype', { value: 'BSONRegExp' });
3543
- //# sourceMappingURL=regexp.js.map
3544
- });
3545
-
3546
- unwrapExports(regexp);
3547
- regexp.BSONRegExp;
3548
2761
 
3549
- var symbol = createCommonjsModule(function (module, exports) {
3550
- Object.defineProperty(exports, "__esModule", { value: true });
3551
- exports.BSONSymbol = void 0;
3552
2762
  /**
3553
2763
  * A class representation of the BSON Symbol type.
3554
2764
  * @public
@@ -3566,7 +2776,6 @@ var BSONSymbol = /** @class */ (function () {
3566
2776
  BSONSymbol.prototype.valueOf = function () {
3567
2777
  return this.value;
3568
2778
  };
3569
- /** @internal */
3570
2779
  BSONSymbol.prototype.toString = function () {
3571
2780
  return this.value;
3572
2781
  };
@@ -3574,7 +2783,6 @@ var BSONSymbol = /** @class */ (function () {
3574
2783
  BSONSymbol.prototype.inspect = function () {
3575
2784
  return "new BSONSymbol(\"" + this.value + "\")";
3576
2785
  };
3577
- /** @internal */
3578
2786
  BSONSymbol.prototype.toJSON = function () {
3579
2787
  return this.value;
3580
2788
  };
@@ -3592,13 +2800,7 @@ var BSONSymbol = /** @class */ (function () {
3592
2800
  };
3593
2801
  return BSONSymbol;
3594
2802
  }());
3595
- exports.BSONSymbol = BSONSymbol;
3596
2803
  Object.defineProperty(BSONSymbol.prototype, '_bsontype', { value: 'Symbol' });
3597
- //# sourceMappingURL=symbol.js.map
3598
- });
3599
-
3600
- unwrapExports(symbol);
3601
- symbol.BSONSymbol;
3602
2804
 
3603
2805
  /*! *****************************************************************************
3604
2806
  Copyright (c) Microsoft Corporation.
@@ -3640,435 +2842,23 @@ function __extends(d, b) {
3640
2842
  d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
3641
2843
  }
3642
2844
 
3643
- var _assign = function __assign() {
3644
- _assign = Object.assign || function __assign(t) {
3645
- for (var s, i = 1, n = arguments.length; i < n; i++) {
3646
- s = arguments[i];
3647
-
3648
- for (var p in s) {
3649
- if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
3650
- }
3651
- }
3652
-
3653
- return t;
3654
- };
3655
-
3656
- return _assign.apply(this, arguments);
3657
- };
3658
- function __rest(s, e) {
3659
- var t = {};
3660
-
3661
- for (var p in s) {
3662
- if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
3663
- }
3664
-
3665
- if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
3666
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
3667
- }
3668
- return t;
3669
- }
3670
- function __decorate(decorators, target, key, desc) {
3671
- var c = arguments.length,
3672
- r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
3673
- d;
3674
- 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--) {
3675
- if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
3676
- }
3677
- return c > 3 && r && Object.defineProperty(target, key, r), r;
3678
- }
3679
- function __param(paramIndex, decorator) {
3680
- return function (target, key) {
3681
- decorator(target, key, paramIndex);
3682
- };
3683
- }
3684
- function __metadata(metadataKey, metadataValue) {
3685
- if ((typeof Reflect === "undefined" ? "undefined" : babelHelpers["typeof"](Reflect)) === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
3686
- }
3687
- function __awaiter(thisArg, _arguments, P, generator) {
3688
- function adopt(value) {
3689
- return value instanceof P ? value : new P(function (resolve) {
3690
- resolve(value);
3691
- });
3692
- }
3693
-
3694
- return new (P || (P = Promise))(function (resolve, reject) {
3695
- function fulfilled(value) {
3696
- try {
3697
- step(generator.next(value));
3698
- } catch (e) {
3699
- reject(e);
3700
- }
3701
- }
3702
-
3703
- function rejected(value) {
3704
- try {
3705
- step(generator["throw"](value));
3706
- } catch (e) {
3707
- reject(e);
3708
- }
3709
- }
3710
-
3711
- function step(result) {
3712
- result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
3713
- }
3714
-
3715
- step((generator = generator.apply(thisArg, _arguments || [])).next());
3716
- });
3717
- }
3718
- function __generator(thisArg, body) {
3719
- var _ = {
3720
- label: 0,
3721
- sent: function sent() {
3722
- if (t[0] & 1) throw t[1];
3723
- return t[1];
3724
- },
3725
- trys: [],
3726
- ops: []
3727
- },
3728
- f,
3729
- y,
3730
- t,
3731
- g;
3732
- return g = {
3733
- next: verb(0),
3734
- "throw": verb(1),
3735
- "return": verb(2)
3736
- }, typeof Symbol === "function" && (g[Symbol.iterator] = function () {
3737
- return this;
3738
- }), g;
3739
-
3740
- function verb(n) {
3741
- return function (v) {
3742
- return step([n, v]);
3743
- };
3744
- }
3745
-
3746
- function step(op) {
3747
- if (f) throw new TypeError("Generator is already executing.");
3748
-
3749
- while (_) {
3750
- try {
3751
- 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;
3752
- if (y = 0, t) op = [op[0] & 2, t.value];
3753
-
3754
- switch (op[0]) {
3755
- case 0:
3756
- case 1:
3757
- t = op;
3758
- break;
3759
-
3760
- case 4:
3761
- _.label++;
3762
- return {
3763
- value: op[1],
3764
- done: false
3765
- };
3766
-
3767
- case 5:
3768
- _.label++;
3769
- y = op[1];
3770
- op = [0];
3771
- continue;
3772
-
3773
- case 7:
3774
- op = _.ops.pop();
3775
-
3776
- _.trys.pop();
3777
-
3778
- continue;
3779
-
3780
- default:
3781
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
3782
- _ = 0;
3783
- continue;
3784
- }
3785
-
3786
- if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
3787
- _.label = op[1];
3788
- break;
3789
- }
3790
-
3791
- if (op[0] === 6 && _.label < t[1]) {
3792
- _.label = t[1];
3793
- t = op;
3794
- break;
3795
- }
3796
-
3797
- if (t && _.label < t[2]) {
3798
- _.label = t[2];
3799
-
3800
- _.ops.push(op);
3801
-
3802
- break;
3803
- }
3804
-
3805
- if (t[2]) _.ops.pop();
3806
-
3807
- _.trys.pop();
3808
-
3809
- continue;
3810
- }
3811
-
3812
- op = body.call(thisArg, _);
3813
- } catch (e) {
3814
- op = [6, e];
3815
- y = 0;
3816
- } finally {
3817
- f = t = 0;
3818
- }
3819
- }
3820
-
3821
- if (op[0] & 5) throw op[1];
3822
- return {
3823
- value: op[0] ? op[1] : void 0,
3824
- done: true
3825
- };
3826
- }
3827
- }
3828
- function __createBinding(o, m, k, k2) {
3829
- if (k2 === undefined) k2 = k;
3830
- o[k2] = m[k];
3831
- }
3832
- function __exportStar(m, exports) {
3833
- for (var p in m) {
3834
- if (p !== "default" && !exports.hasOwnProperty(p)) exports[p] = m[p];
3835
- }
3836
- }
3837
- function __values(o) {
3838
- var s = typeof Symbol === "function" && Symbol.iterator,
3839
- m = s && o[s],
3840
- i = 0;
3841
- if (m) return m.call(o);
3842
- if (o && typeof o.length === "number") return {
3843
- next: function next() {
3844
- if (o && i >= o.length) o = void 0;
3845
- return {
3846
- value: o && o[i++],
3847
- done: !o
3848
- };
3849
- }
3850
- };
3851
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
3852
- }
3853
- function __read(o, n) {
3854
- var m = typeof Symbol === "function" && o[Symbol.iterator];
3855
- if (!m) return o;
3856
- var i = m.call(o),
3857
- r,
3858
- ar = [],
3859
- e;
3860
-
3861
- try {
3862
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) {
3863
- ar.push(r.value);
3864
- }
3865
- } catch (error) {
3866
- e = {
3867
- error: error
3868
- };
3869
- } finally {
3870
- try {
3871
- if (r && !r.done && (m = i["return"])) m.call(i);
3872
- } finally {
3873
- if (e) throw e.error;
3874
- }
3875
- }
3876
-
3877
- return ar;
3878
- }
3879
- function __spread() {
3880
- for (var ar = [], i = 0; i < arguments.length; i++) {
3881
- ar = ar.concat(__read(arguments[i]));
3882
- }
3883
-
3884
- return ar;
3885
- }
3886
- function __spreadArrays() {
3887
- for (var s = 0, i = 0, il = arguments.length; i < il; i++) {
3888
- s += arguments[i].length;
3889
- }
3890
-
3891
- for (var r = Array(s), k = 0, i = 0; i < il; i++) {
3892
- for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++) {
3893
- r[k] = a[j];
3894
- }
3895
- }
3896
-
3897
- return r;
3898
- }
3899
- function __await(v) {
3900
- return this instanceof __await ? (this.v = v, this) : new __await(v);
3901
- }
3902
- function __asyncGenerator(thisArg, _arguments, generator) {
3903
- if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
3904
- var g = generator.apply(thisArg, _arguments || []),
3905
- i,
3906
- q = [];
3907
- return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () {
3908
- return this;
3909
- }, i;
3910
-
3911
- function verb(n) {
3912
- if (g[n]) i[n] = function (v) {
3913
- return new Promise(function (a, b) {
3914
- q.push([n, v, a, b]) > 1 || resume(n, v);
3915
- });
3916
- };
3917
- }
3918
-
3919
- function resume(n, v) {
3920
- try {
3921
- step(g[n](v));
3922
- } catch (e) {
3923
- settle(q[0][3], e);
3924
- }
3925
- }
3926
-
3927
- function step(r) {
3928
- r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r);
3929
- }
3930
-
3931
- function fulfill(value) {
3932
- resume("next", value);
3933
- }
3934
-
3935
- function reject(value) {
3936
- resume("throw", value);
3937
- }
3938
-
3939
- function settle(f, v) {
3940
- if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]);
3941
- }
3942
- }
3943
- function __asyncDelegator(o) {
3944
- var i, p;
3945
- return i = {}, verb("next"), verb("throw", function (e) {
3946
- throw e;
3947
- }), verb("return"), i[Symbol.iterator] = function () {
3948
- return this;
3949
- }, i;
3950
-
3951
- function verb(n, f) {
3952
- i[n] = o[n] ? function (v) {
3953
- return (p = !p) ? {
3954
- value: __await(o[n](v)),
3955
- done: n === "return"
3956
- } : f ? f(v) : v;
3957
- } : f;
3958
- }
3959
- }
3960
- function __asyncValues(o) {
3961
- if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
3962
- var m = o[Symbol.asyncIterator],
3963
- i;
3964
- 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 () {
3965
- return this;
3966
- }, i);
3967
-
3968
- function verb(n) {
3969
- i[n] = o[n] && function (v) {
3970
- return new Promise(function (resolve, reject) {
3971
- v = o[n](v), settle(resolve, reject, v.done, v.value);
3972
- });
3973
- };
3974
- }
3975
-
3976
- function settle(resolve, reject, d, v) {
3977
- Promise.resolve(v).then(function (v) {
3978
- resolve({
3979
- value: v,
3980
- done: d
3981
- });
3982
- }, reject);
3983
- }
3984
- }
3985
- function __makeTemplateObject(cooked, raw) {
3986
- if (Object.defineProperty) {
3987
- Object.defineProperty(cooked, "raw", {
3988
- value: raw
3989
- });
3990
- } else {
3991
- cooked.raw = raw;
3992
- }
3993
-
3994
- return cooked;
3995
- }
3996
- function __importStar(mod) {
3997
- if (mod && mod.__esModule) return mod;
3998
- var result = {};
3999
- if (mod != null) for (var k in mod) {
4000
- if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
4001
- }
4002
- result["default"] = mod;
4003
- return result;
4004
- }
4005
- function __importDefault(mod) {
4006
- return mod && mod.__esModule ? mod : {
4007
- "default": mod
4008
- };
4009
- }
4010
- function __classPrivateFieldGet(receiver, privateMap) {
4011
- if (!privateMap.has(receiver)) {
4012
- throw new TypeError("attempted to get private field on non-instance");
4013
- }
4014
-
4015
- return privateMap.get(receiver);
4016
- }
4017
- function __classPrivateFieldSet(receiver, privateMap, value) {
4018
- if (!privateMap.has(receiver)) {
4019
- throw new TypeError("attempted to set private field on non-instance");
4020
- }
4021
-
4022
- privateMap.set(receiver, value);
4023
- return value;
4024
- }
4025
-
4026
- var tslib_es6 = /*#__PURE__*/Object.freeze({
4027
- __proto__: null,
4028
- __extends: __extends,
4029
- get __assign () { return _assign; },
4030
- __rest: __rest,
4031
- __decorate: __decorate,
4032
- __param: __param,
4033
- __metadata: __metadata,
4034
- __awaiter: __awaiter,
4035
- __generator: __generator,
4036
- __createBinding: __createBinding,
4037
- __exportStar: __exportStar,
4038
- __values: __values,
4039
- __read: __read,
4040
- __spread: __spread,
4041
- __spreadArrays: __spreadArrays,
4042
- __await: __await,
4043
- __asyncGenerator: __asyncGenerator,
4044
- __asyncDelegator: __asyncDelegator,
4045
- __asyncValues: __asyncValues,
4046
- __makeTemplateObject: __makeTemplateObject,
4047
- __importStar: __importStar,
4048
- __importDefault: __importDefault,
4049
- __classPrivateFieldGet: __classPrivateFieldGet,
4050
- __classPrivateFieldSet: __classPrivateFieldSet
4051
- });
4052
-
4053
- var timestamp = createCommonjsModule(function (module, exports) {
4054
- Object.defineProperty(exports, "__esModule", { value: true });
4055
- exports.Timestamp = exports.LongWithoutOverridesClass = void 0;
4056
-
4057
-
4058
2845
  /** @public */
4059
- exports.LongWithoutOverridesClass = long_1.Long;
2846
+ var LongWithoutOverridesClass = Long;
4060
2847
  /** @public */
4061
2848
  var Timestamp = /** @class */ (function (_super) {
4062
- tslib_es6.__extends(Timestamp, _super);
2849
+ __extends(Timestamp, _super);
4063
2850
  function Timestamp(low, high) {
4064
2851
  var _this = this;
4065
2852
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
4066
2853
  ///@ts-expect-error
4067
2854
  if (!(_this instanceof Timestamp))
4068
2855
  return new Timestamp(low, high);
4069
- if (long_1.Long.isLong(low)) {
2856
+ if (Long.isLong(low)) {
4070
2857
  _this = _super.call(this, low.low, low.high, true) || this;
4071
2858
  }
2859
+ else if (isObjectLike(low) && typeof low.t !== 'undefined' && typeof low.i !== 'undefined') {
2860
+ _this = _super.call(this, low.i, low.t, true) || this;
2861
+ }
4072
2862
  else {
4073
2863
  _this = _super.call(this, low, high, true) || this;
4074
2864
  }
@@ -4087,11 +2877,11 @@ var Timestamp = /** @class */ (function (_super) {
4087
2877
  };
4088
2878
  /** Returns a Timestamp represented by the given (32-bit) integer value. */
4089
2879
  Timestamp.fromInt = function (value) {
4090
- return new Timestamp(long_1.Long.fromInt(value, true));
2880
+ return new Timestamp(Long.fromInt(value, true));
4091
2881
  };
4092
2882
  /** Returns a Timestamp representing the given number value, provided that it is a finite number. Otherwise, zero is returned. */
4093
2883
  Timestamp.fromNumber = function (value) {
4094
- return new Timestamp(long_1.Long.fromNumber(value, true));
2884
+ return new Timestamp(Long.fromNumber(value, true));
4095
2885
  };
4096
2886
  /**
4097
2887
  * Returns a Timestamp for the given high and low bits. Each is assumed to use 32 bits.
@@ -4109,7 +2899,7 @@ var Timestamp = /** @class */ (function (_super) {
4109
2899
  * @param optRadix - the radix in which the text is written.
4110
2900
  */
4111
2901
  Timestamp.fromString = function (str, optRadix) {
4112
- return new Timestamp(long_1.Long.fromString(str, true, optRadix));
2902
+ return new Timestamp(Long.fromString(str, true, optRadix));
4113
2903
  };
4114
2904
  /** @internal */
4115
2905
  Timestamp.prototype.toExtendedJSON = function () {
@@ -4117,69 +2907,44 @@ var Timestamp = /** @class */ (function (_super) {
4117
2907
  };
4118
2908
  /** @internal */
4119
2909
  Timestamp.fromExtendedJSON = function (doc) {
4120
- return new Timestamp(doc.$timestamp.i, doc.$timestamp.t);
2910
+ return new Timestamp(doc.$timestamp);
4121
2911
  };
4122
2912
  /** @internal */
4123
2913
  Timestamp.prototype[Symbol.for('nodejs.util.inspect.custom')] = function () {
4124
2914
  return this.inspect();
4125
2915
  };
4126
2916
  Timestamp.prototype.inspect = function () {
4127
- return "new Timestamp(" + this.getLowBits().toString() + ", " + this.getHighBits().toString() + ")";
2917
+ return "new Timestamp({ t: " + this.getHighBits() + ", i: " + this.getLowBits() + " })";
4128
2918
  };
4129
- Timestamp.MAX_VALUE = long_1.Long.MAX_UNSIGNED_VALUE;
2919
+ Timestamp.MAX_VALUE = Long.MAX_UNSIGNED_VALUE;
4130
2920
  return Timestamp;
4131
- }(exports.LongWithoutOverridesClass));
4132
- exports.Timestamp = Timestamp;
4133
- //# sourceMappingURL=timestamp.js.map
4134
- });
4135
-
4136
- unwrapExports(timestamp);
4137
- timestamp.Timestamp;
4138
- timestamp.LongWithoutOverridesClass;
4139
-
4140
- var extended_json = createCommonjsModule(function (module, exports) {
4141
- Object.defineProperty(exports, "__esModule", { value: true });
4142
- exports.EJSON = exports.isBSONType = void 0;
4143
-
4144
-
4145
-
4146
-
4147
-
4148
-
4149
-
4150
-
4151
-
4152
-
4153
-
4154
-
4155
-
2921
+ }(LongWithoutOverridesClass));
4156
2922
 
4157
2923
  function isBSONType(value) {
4158
- return (utils.isObjectLike(value) && Reflect.has(value, '_bsontype') && typeof value._bsontype === 'string');
2924
+ return (isObjectLike(value) && Reflect.has(value, '_bsontype') && typeof value._bsontype === 'string');
4159
2925
  }
4160
- exports.isBSONType = isBSONType;
4161
2926
  // INT32 boundaries
4162
- var BSON_INT32_MAX = 0x7fffffff;
4163
- var BSON_INT32_MIN = -0x80000000;
2927
+ var BSON_INT32_MAX$1 = 0x7fffffff;
2928
+ var BSON_INT32_MIN$1 = -0x80000000;
4164
2929
  // INT64 boundaries
4165
- var BSON_INT64_MAX = 0x7fffffffffffffff;
4166
- var BSON_INT64_MIN = -0x8000000000000000;
2930
+ var BSON_INT64_MAX$1 = 0x7fffffffffffffff;
2931
+ var BSON_INT64_MIN$1 = -0x8000000000000000;
4167
2932
  // all the types where we don't need to do any special processing and can just pass the EJSON
4168
2933
  //straight to type.fromExtendedJSON
4169
2934
  var keysToCodecs = {
4170
- $oid: objectid.ObjectId,
4171
- $binary: binary.Binary,
4172
- $uuid: binary.Binary,
4173
- $symbol: symbol.BSONSymbol,
4174
- $numberInt: int_32.Int32,
4175
- $numberDecimal: decimal128.Decimal128,
4176
- $numberDouble: double_1.Double,
4177
- $numberLong: long_1.Long,
4178
- $minKey: min_key.MinKey,
4179
- $maxKey: max_key.MaxKey,
4180
- $regex: regexp.BSONRegExp,
4181
- $regularExpression: regexp.BSONRegExp,
4182
- $timestamp: timestamp.Timestamp
2935
+ $oid: ObjectId,
2936
+ $binary: Binary,
2937
+ $uuid: Binary,
2938
+ $symbol: BSONSymbol,
2939
+ $numberInt: Int32,
2940
+ $numberDecimal: Decimal128,
2941
+ $numberDouble: Double,
2942
+ $numberLong: Long,
2943
+ $minKey: MinKey,
2944
+ $maxKey: MaxKey,
2945
+ $regex: BSONRegExp,
2946
+ $regularExpression: BSONRegExp,
2947
+ $timestamp: Timestamp
4183
2948
  };
4184
2949
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
4185
2950
  function deserializeValue(value, options) {
@@ -4191,13 +2956,13 @@ function deserializeValue(value, options) {
4191
2956
  // if it's an integer, should interpret as smallest BSON integer
4192
2957
  // that can represent it exactly. (if out of range, interpret as double.)
4193
2958
  if (Math.floor(value) === value) {
4194
- if (value >= BSON_INT32_MIN && value <= BSON_INT32_MAX)
4195
- return new int_32.Int32(value);
4196
- if (value >= BSON_INT64_MIN && value <= BSON_INT64_MAX)
4197
- return long_1.Long.fromNumber(value);
2959
+ if (value >= BSON_INT32_MIN$1 && value <= BSON_INT32_MAX$1)
2960
+ return new Int32(value);
2961
+ if (value >= BSON_INT64_MIN$1 && value <= BSON_INT64_MAX$1)
2962
+ return Long.fromNumber(value);
4198
2963
  }
4199
2964
  // If the number is a non-integer or out of integer range, should interpret as BSON Double.
4200
- return new double_1.Double(value);
2965
+ return new Double(value);
4201
2966
  }
4202
2967
  // from here on out we're looking for bson types, so bail if its not an object
4203
2968
  if (value == null || typeof value !== 'object')
@@ -4223,7 +2988,7 @@ function deserializeValue(value, options) {
4223
2988
  else {
4224
2989
  if (typeof d === 'string')
4225
2990
  date.setTime(Date.parse(d));
4226
- else if (long_1.Long.isLong(d))
2991
+ else if (Long.isLong(d))
4227
2992
  date.setTime(d.toNumber());
4228
2993
  else if (typeof d === 'number' && options.relaxed)
4229
2994
  date.setTime(d);
@@ -4235,13 +3000,13 @@ function deserializeValue(value, options) {
4235
3000
  if (value.$scope) {
4236
3001
  copy.$scope = deserializeValue(value.$scope);
4237
3002
  }
4238
- return code.Code.fromExtendedJSON(value);
3003
+ return Code.fromExtendedJSON(value);
4239
3004
  }
4240
- if (value.$ref != null || value.$dbPointer != null) {
3005
+ if (isDBRefLike(value) || value.$dbPointer) {
4241
3006
  var v = value.$ref ? value : value.$dbPointer;
4242
3007
  // we run into this in a "degenerate EJSON" case (with $id and $ref order flipped)
4243
3008
  // because of the order JSON.parse goes through the document
4244
- if (v instanceof db_ref.DBRef)
3009
+ if (v instanceof DBRef)
4245
3010
  return v;
4246
3011
  var dollarKeys = Object.keys(v).filter(function (k) { return k.startsWith('$'); });
4247
3012
  var valid_1 = true;
@@ -4251,7 +3016,7 @@ function deserializeValue(value, options) {
4251
3016
  });
4252
3017
  // only make DBRef if $ keys are all valid
4253
3018
  if (valid_1)
4254
- return db_ref.DBRef.fromExtendedJSON(v);
3019
+ return DBRef.fromExtendedJSON(v);
4255
3020
  }
4256
3021
  return value;
4257
3022
  }
@@ -4301,7 +3066,7 @@ function serializeValue(value, options) {
4301
3066
  return serializeArray(value, options);
4302
3067
  if (value === undefined)
4303
3068
  return null;
4304
- if (value instanceof Date || utils.isDate(value)) {
3069
+ if (value instanceof Date || isDate(value)) {
4305
3070
  var dateNum = value.getTime(),
4306
3071
  // is it in year range 1970-9999?
4307
3072
  inRange = dateNum > -1 && dateNum < 253402318800000;
@@ -4314,10 +3079,10 @@ function serializeValue(value, options) {
4314
3079
  ? { $date: getISOString(value) }
4315
3080
  : { $date: { $numberLong: value.getTime().toString() } };
4316
3081
  }
4317
- if (typeof value === 'number' && !options.relaxed) {
3082
+ if (typeof value === 'number' && (!options.relaxed || !isFinite(value))) {
4318
3083
  // it's an integer
4319
3084
  if (Math.floor(value) === value) {
4320
- var int32Range = value >= BSON_INT32_MIN && value <= BSON_INT32_MAX, int64Range = value >= BSON_INT64_MIN && value <= BSON_INT64_MAX;
3085
+ var int32Range = value >= BSON_INT32_MIN$1 && value <= BSON_INT32_MAX$1, int64Range = value >= BSON_INT64_MIN$1 && value <= BSON_INT64_MAX$1;
4321
3086
  // interpret as being of the smallest BSON integer type that can represent the number exactly
4322
3087
  if (int32Range)
4323
3088
  return { $numberInt: value.toString() };
@@ -4326,7 +3091,7 @@ function serializeValue(value, options) {
4326
3091
  }
4327
3092
  return { $numberDouble: value.toString() };
4328
3093
  }
4329
- if (value instanceof RegExp || utils.isRegExp(value)) {
3094
+ if (value instanceof RegExp || isRegExp(value)) {
4330
3095
  var flags = value.flags;
4331
3096
  if (flags === undefined) {
4332
3097
  var match = value.toString().match(/[gimuy]*$/);
@@ -4334,7 +3099,7 @@ function serializeValue(value, options) {
4334
3099
  flags = match[0];
4335
3100
  }
4336
3101
  }
4337
- var rx = new regexp.BSONRegExp(value.source, flags);
3102
+ var rx = new BSONRegExp(value.source, flags);
4338
3103
  return rx.toExtendedJSON(options);
4339
3104
  }
4340
3105
  if (value != null && typeof value === 'object')
@@ -4342,24 +3107,24 @@ function serializeValue(value, options) {
4342
3107
  return value;
4343
3108
  }
4344
3109
  var BSON_TYPE_MAPPINGS = {
4345
- Binary: function (o) { return new binary.Binary(o.value(), o.sub_type); },
4346
- Code: function (o) { return new code.Code(o.code, o.scope); },
4347
- DBRef: function (o) { return new db_ref.DBRef(o.collection || o.namespace, o.oid, o.db, o.fields); },
4348
- Decimal128: function (o) { return new decimal128.Decimal128(o.bytes); },
4349
- Double: function (o) { return new double_1.Double(o.value); },
4350
- Int32: function (o) { return new int_32.Int32(o.value); },
3110
+ Binary: function (o) { return new Binary(o.value(), o.sub_type); },
3111
+ Code: function (o) { return new Code(o.code, o.scope); },
3112
+ DBRef: function (o) { return new DBRef(o.collection || o.namespace, o.oid, o.db, o.fields); },
3113
+ Decimal128: function (o) { return new Decimal128(o.bytes); },
3114
+ Double: function (o) { return new Double(o.value); },
3115
+ Int32: function (o) { return new Int32(o.value); },
4351
3116
  Long: function (o) {
4352
- return long_1.Long.fromBits(
3117
+ return Long.fromBits(
4353
3118
  // underscore variants for 1.x backwards compatibility
4354
3119
  o.low != null ? o.low : o.low_, o.low != null ? o.high : o.high_, o.low != null ? o.unsigned : o.unsigned_);
4355
3120
  },
4356
- MaxKey: function () { return new max_key.MaxKey(); },
4357
- MinKey: function () { return new min_key.MinKey(); },
4358
- ObjectID: function (o) { return new objectid.ObjectId(o); },
4359
- ObjectId: function (o) { return new objectid.ObjectId(o); },
4360
- BSONRegExp: function (o) { return new regexp.BSONRegExp(o.pattern, o.options); },
4361
- Symbol: function (o) { return new symbol.BSONSymbol(o.value); },
4362
- Timestamp: function (o) { return timestamp.Timestamp.fromBits(o.low, o.high); }
3121
+ MaxKey: function () { return new MaxKey(); },
3122
+ MinKey: function () { return new MinKey(); },
3123
+ ObjectID: function (o) { return new ObjectId(o); },
3124
+ ObjectId: function (o) { return new ObjectId(o); },
3125
+ BSONRegExp: function (o) { return new BSONRegExp(o.pattern, o.options); },
3126
+ Symbol: function (o) { return new BSONSymbol(o.value); },
3127
+ Timestamp: function (o) { return Timestamp.fromBits(o.low, o.high); }
4363
3128
  };
4364
3129
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
4365
3130
  function serializeDocument(doc, options) {
@@ -4397,10 +3162,10 @@ function serializeDocument(doc, options) {
4397
3162
  }
4398
3163
  // Two BSON types may have nested objects that may need to be serialized too
4399
3164
  if (bsontype === 'Code' && outDoc.scope) {
4400
- outDoc = new code.Code(outDoc.code, serializeValue(outDoc.scope, options));
3165
+ outDoc = new Code(outDoc.code, serializeValue(outDoc.scope, options));
4401
3166
  }
4402
3167
  else if (bsontype === 'DBRef' && outDoc.oid) {
4403
- outDoc = new db_ref.DBRef(outDoc.collection, serializeValue(outDoc.oid, options), outDoc.db, outDoc.fields);
3168
+ outDoc = new DBRef(serializeValue(outDoc.collection, options), serializeValue(outDoc.oid, options), serializeValue(outDoc.db, options), serializeValue(outDoc.fields, options));
4404
3169
  }
4405
3170
  return outDoc.toExtendedJSON(options);
4406
3171
  }
@@ -4408,6 +3173,14 @@ function serializeDocument(doc, options) {
4408
3173
  throw new Error('_bsontype must be a string, but was: ' + typeof bsontype);
4409
3174
  }
4410
3175
  }
3176
+ /**
3177
+ * EJSON parse / stringify API
3178
+ * @public
3179
+ */
3180
+ // the namespace here is used to emulate `export * as EJSON from '...'`
3181
+ // which as of now (sept 2020) api-extractor does not support
3182
+ // eslint-disable-next-line @typescript-eslint/no-namespace
3183
+ var EJSON;
4411
3184
  (function (EJSON) {
4412
3185
  /**
4413
3186
  * Parse an Extended JSON string, constructing the JavaScript value or object described by that
@@ -4499,42 +3272,18 @@ function serializeDocument(doc, options) {
4499
3272
  return parse(JSON.stringify(ejson), options);
4500
3273
  }
4501
3274
  EJSON.deserialize = deserialize;
4502
- })(exports.EJSON || (exports.EJSON = {}));
4503
- //# sourceMappingURL=extended_json.js.map
4504
- });
3275
+ })(EJSON || (EJSON = {}));
4505
3276
 
4506
- unwrapExports(extended_json);
4507
- extended_json.EJSON;
4508
- extended_json.isBSONType;
4509
-
4510
- var map = createCommonjsModule(function (module, exports) {
4511
3277
  /* eslint-disable @typescript-eslint/no-explicit-any */
4512
- // We have an ES6 Map available, return the native instance
4513
- Object.defineProperty(exports, "__esModule", { value: true });
4514
- exports.Map = void 0;
4515
3278
  /** @public */
4516
3279
  var bsonMap;
4517
- exports.Map = bsonMap;
4518
- var check = function (potentialGlobal) {
4519
- // eslint-disable-next-line eqeqeq
4520
- return potentialGlobal && potentialGlobal.Math == Math && potentialGlobal;
4521
- };
4522
- // https://github.com/zloirock/core-js/issues/86#issuecomment-115759028
4523
- function getGlobal() {
4524
- // eslint-disable-next-line no-undef
4525
- return (check(typeof globalThis === 'object' && globalThis) ||
4526
- check(typeof window === 'object' && window) ||
4527
- check(typeof self === 'object' && self) ||
4528
- check(typeof commonjsGlobal === 'object' && commonjsGlobal) ||
4529
- Function('return this')());
4530
- }
4531
3280
  var bsonGlobal = getGlobal();
4532
- if (Object.prototype.hasOwnProperty.call(bsonGlobal, 'Map')) {
4533
- exports.Map = bsonMap = bsonGlobal.Map;
3281
+ if (bsonGlobal.Map) {
3282
+ bsonMap = bsonGlobal.Map;
4534
3283
  }
4535
3284
  else {
4536
3285
  // We will return a polyfill
4537
- exports.Map = bsonMap = /** @class */ (function () {
3286
+ bsonMap = /** @class */ (function () {
4538
3287
  function Map(array) {
4539
3288
  if (array === void 0) { array = []; }
4540
3289
  this._keys = [];
@@ -4641,136 +3390,83 @@ else {
4641
3390
  return Map;
4642
3391
  }());
4643
3392
  }
4644
- //# sourceMappingURL=map.js.map
4645
- });
4646
3393
 
4647
- unwrapExports(map);
4648
- map.Map;
4649
-
4650
- var constants = createCommonjsModule(function (module, exports) {
4651
- Object.defineProperty(exports, "__esModule", { value: true });
4652
- 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;
4653
3394
  /** @internal */
4654
- exports.BSON_INT32_MAX = 0x7fffffff;
3395
+ var BSON_INT32_MAX = 0x7fffffff;
4655
3396
  /** @internal */
4656
- exports.BSON_INT32_MIN = -0x80000000;
3397
+ var BSON_INT32_MIN = -0x80000000;
4657
3398
  /** @internal */
4658
- exports.BSON_INT64_MAX = Math.pow(2, 63) - 1;
3399
+ var BSON_INT64_MAX = Math.pow(2, 63) - 1;
4659
3400
  /** @internal */
4660
- exports.BSON_INT64_MIN = -Math.pow(2, 63);
3401
+ var BSON_INT64_MIN = -Math.pow(2, 63);
4661
3402
  /**
4662
3403
  * Any integer up to 2^53 can be precisely represented by a double.
4663
3404
  * @internal
4664
3405
  */
4665
- exports.JS_INT_MAX = Math.pow(2, 53);
3406
+ var JS_INT_MAX = Math.pow(2, 53);
4666
3407
  /**
4667
3408
  * Any integer down to -2^53 can be precisely represented by a double.
4668
3409
  * @internal
4669
3410
  */
4670
- exports.JS_INT_MIN = -Math.pow(2, 53);
3411
+ var JS_INT_MIN = -Math.pow(2, 53);
4671
3412
  /** Number BSON Type @internal */
4672
- exports.BSON_DATA_NUMBER = 1;
3413
+ var BSON_DATA_NUMBER = 1;
4673
3414
  /** String BSON Type @internal */
4674
- exports.BSON_DATA_STRING = 2;
3415
+ var BSON_DATA_STRING = 2;
4675
3416
  /** Object BSON Type @internal */
4676
- exports.BSON_DATA_OBJECT = 3;
3417
+ var BSON_DATA_OBJECT = 3;
4677
3418
  /** Array BSON Type @internal */
4678
- exports.BSON_DATA_ARRAY = 4;
3419
+ var BSON_DATA_ARRAY = 4;
4679
3420
  /** Binary BSON Type @internal */
4680
- exports.BSON_DATA_BINARY = 5;
3421
+ var BSON_DATA_BINARY = 5;
4681
3422
  /** Binary BSON Type @internal */
4682
- exports.BSON_DATA_UNDEFINED = 6;
3423
+ var BSON_DATA_UNDEFINED = 6;
4683
3424
  /** ObjectId BSON Type @internal */
4684
- exports.BSON_DATA_OID = 7;
3425
+ var BSON_DATA_OID = 7;
4685
3426
  /** Boolean BSON Type @internal */
4686
- exports.BSON_DATA_BOOLEAN = 8;
3427
+ var BSON_DATA_BOOLEAN = 8;
4687
3428
  /** Date BSON Type @internal */
4688
- exports.BSON_DATA_DATE = 9;
3429
+ var BSON_DATA_DATE = 9;
4689
3430
  /** null BSON Type @internal */
4690
- exports.BSON_DATA_NULL = 10;
3431
+ var BSON_DATA_NULL = 10;
4691
3432
  /** RegExp BSON Type @internal */
4692
- exports.BSON_DATA_REGEXP = 11;
3433
+ var BSON_DATA_REGEXP = 11;
4693
3434
  /** Code BSON Type @internal */
4694
- exports.BSON_DATA_DBPOINTER = 12;
3435
+ var BSON_DATA_DBPOINTER = 12;
4695
3436
  /** Code BSON Type @internal */
4696
- exports.BSON_DATA_CODE = 13;
3437
+ var BSON_DATA_CODE = 13;
4697
3438
  /** Symbol BSON Type @internal */
4698
- exports.BSON_DATA_SYMBOL = 14;
3439
+ var BSON_DATA_SYMBOL = 14;
4699
3440
  /** Code with Scope BSON Type @internal */
4700
- exports.BSON_DATA_CODE_W_SCOPE = 15;
3441
+ var BSON_DATA_CODE_W_SCOPE = 15;
4701
3442
  /** 32 bit Integer BSON Type @internal */
4702
- exports.BSON_DATA_INT = 16;
3443
+ var BSON_DATA_INT = 16;
4703
3444
  /** Timestamp BSON Type @internal */
4704
- exports.BSON_DATA_TIMESTAMP = 17;
3445
+ var BSON_DATA_TIMESTAMP = 17;
4705
3446
  /** Long BSON Type @internal */
4706
- exports.BSON_DATA_LONG = 18;
3447
+ var BSON_DATA_LONG = 18;
4707
3448
  /** Decimal128 BSON Type @internal */
4708
- exports.BSON_DATA_DECIMAL128 = 19;
3449
+ var BSON_DATA_DECIMAL128 = 19;
4709
3450
  /** MinKey BSON Type @internal */
4710
- exports.BSON_DATA_MIN_KEY = 0xff;
3451
+ var BSON_DATA_MIN_KEY = 0xff;
4711
3452
  /** MaxKey BSON Type @internal */
4712
- exports.BSON_DATA_MAX_KEY = 0x7f;
3453
+ var BSON_DATA_MAX_KEY = 0x7f;
4713
3454
  /** Binary Default Type @internal */
4714
- exports.BSON_BINARY_SUBTYPE_DEFAULT = 0;
3455
+ var BSON_BINARY_SUBTYPE_DEFAULT = 0;
4715
3456
  /** Binary Function Type @internal */
4716
- exports.BSON_BINARY_SUBTYPE_FUNCTION = 1;
3457
+ var BSON_BINARY_SUBTYPE_FUNCTION = 1;
4717
3458
  /** Binary Byte Array Type @internal */
4718
- exports.BSON_BINARY_SUBTYPE_BYTE_ARRAY = 2;
3459
+ var BSON_BINARY_SUBTYPE_BYTE_ARRAY = 2;
4719
3460
  /** Binary Deprecated UUID Type @deprecated Please use BSON_BINARY_SUBTYPE_UUID_NEW @internal */
4720
- exports.BSON_BINARY_SUBTYPE_UUID = 3;
3461
+ var BSON_BINARY_SUBTYPE_UUID = 3;
4721
3462
  /** Binary UUID Type @internal */
4722
- exports.BSON_BINARY_SUBTYPE_UUID_NEW = 4;
3463
+ var BSON_BINARY_SUBTYPE_UUID_NEW = 4;
4723
3464
  /** Binary MD5 Type @internal */
4724
- exports.BSON_BINARY_SUBTYPE_MD5 = 5;
3465
+ var BSON_BINARY_SUBTYPE_MD5 = 5;
4725
3466
  /** Binary User Defined Type @internal */
4726
- exports.BSON_BINARY_SUBTYPE_USER_DEFINED = 128;
4727
- //# sourceMappingURL=constants.js.map
4728
- });
3467
+ var BSON_BINARY_SUBTYPE_USER_DEFINED = 128;
4729
3468
 
4730
- unwrapExports(constants);
4731
- constants.BSON_BINARY_SUBTYPE_USER_DEFINED;
4732
- constants.BSON_BINARY_SUBTYPE_MD5;
4733
- constants.BSON_BINARY_SUBTYPE_UUID_NEW;
4734
- constants.BSON_BINARY_SUBTYPE_UUID;
4735
- constants.BSON_BINARY_SUBTYPE_BYTE_ARRAY;
4736
- constants.BSON_BINARY_SUBTYPE_FUNCTION;
4737
- constants.BSON_BINARY_SUBTYPE_DEFAULT;
4738
- constants.BSON_DATA_MAX_KEY;
4739
- constants.BSON_DATA_MIN_KEY;
4740
- constants.BSON_DATA_DECIMAL128;
4741
- constants.BSON_DATA_LONG;
4742
- constants.BSON_DATA_TIMESTAMP;
4743
- constants.BSON_DATA_INT;
4744
- constants.BSON_DATA_CODE_W_SCOPE;
4745
- constants.BSON_DATA_SYMBOL;
4746
- constants.BSON_DATA_CODE;
4747
- constants.BSON_DATA_DBPOINTER;
4748
- constants.BSON_DATA_REGEXP;
4749
- constants.BSON_DATA_NULL;
4750
- constants.BSON_DATA_DATE;
4751
- constants.BSON_DATA_BOOLEAN;
4752
- constants.BSON_DATA_OID;
4753
- constants.BSON_DATA_UNDEFINED;
4754
- constants.BSON_DATA_BINARY;
4755
- constants.BSON_DATA_ARRAY;
4756
- constants.BSON_DATA_OBJECT;
4757
- constants.BSON_DATA_STRING;
4758
- constants.BSON_DATA_NUMBER;
4759
- constants.JS_INT_MIN;
4760
- constants.JS_INT_MAX;
4761
- constants.BSON_INT64_MIN;
4762
- constants.BSON_INT64_MAX;
4763
- constants.BSON_INT32_MIN;
4764
- constants.BSON_INT32_MAX;
4765
-
4766
- var calculate_size = createCommonjsModule(function (module, exports) {
4767
- Object.defineProperty(exports, "__esModule", { value: true });
4768
- exports.calculateObjectSize = void 0;
4769
-
4770
-
4771
-
4772
-
4773
- function calculateObjectSize(object, serializeFunctions, ignoreUndefined) {
3469
+ function calculateObjectSize$1(object, serializeFunctions, ignoreUndefined) {
4774
3470
  var totalLength = 4 + 1;
4775
3471
  if (Array.isArray(object)) {
4776
3472
  for (var i = 0; i < object.length; i++) {
@@ -4789,7 +3485,6 @@ function calculateObjectSize(object, serializeFunctions, ignoreUndefined) {
4789
3485
  }
4790
3486
  return totalLength;
4791
3487
  }
4792
- exports.calculateObjectSize = calculateObjectSize;
4793
3488
  /** @internal */
4794
3489
  function calculateElement(name,
4795
3490
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -4803,84 +3498,84 @@ value, serializeFunctions, isArray, ignoreUndefined) {
4803
3498
  }
4804
3499
  switch (typeof value) {
4805
3500
  case 'string':
4806
- return 1 + buffer.Buffer.byteLength(name, 'utf8') + 1 + 4 + buffer.Buffer.byteLength(value, 'utf8') + 1;
3501
+ return 1 + Buffer.byteLength(name, 'utf8') + 1 + 4 + Buffer.byteLength(value, 'utf8') + 1;
4807
3502
  case 'number':
4808
3503
  if (Math.floor(value) === value &&
4809
- value >= constants.JS_INT_MIN &&
4810
- value <= constants.JS_INT_MAX) {
4811
- if (value >= constants.BSON_INT32_MIN && value <= constants.BSON_INT32_MAX) {
3504
+ value >= JS_INT_MIN &&
3505
+ value <= JS_INT_MAX) {
3506
+ if (value >= BSON_INT32_MIN && value <= BSON_INT32_MAX) {
4812
3507
  // 32 bit
4813
- return (name != null ? buffer.Buffer.byteLength(name, 'utf8') + 1 : 0) + (4 + 1);
3508
+ return (name != null ? Buffer.byteLength(name, 'utf8') + 1 : 0) + (4 + 1);
4814
3509
  }
4815
3510
  else {
4816
- return (name != null ? buffer.Buffer.byteLength(name, 'utf8') + 1 : 0) + (8 + 1);
3511
+ return (name != null ? Buffer.byteLength(name, 'utf8') + 1 : 0) + (8 + 1);
4817
3512
  }
4818
3513
  }
4819
3514
  else {
4820
3515
  // 64 bit
4821
- return (name != null ? buffer.Buffer.byteLength(name, 'utf8') + 1 : 0) + (8 + 1);
3516
+ return (name != null ? Buffer.byteLength(name, 'utf8') + 1 : 0) + (8 + 1);
4822
3517
  }
4823
3518
  case 'undefined':
4824
3519
  if (isArray || !ignoreUndefined)
4825
- return (name != null ? buffer.Buffer.byteLength(name, 'utf8') + 1 : 0) + 1;
3520
+ return (name != null ? Buffer.byteLength(name, 'utf8') + 1 : 0) + 1;
4826
3521
  return 0;
4827
3522
  case 'boolean':
4828
- return (name != null ? buffer.Buffer.byteLength(name, 'utf8') + 1 : 0) + (1 + 1);
3523
+ return (name != null ? Buffer.byteLength(name, 'utf8') + 1 : 0) + (1 + 1);
4829
3524
  case 'object':
4830
3525
  if (value == null || value['_bsontype'] === 'MinKey' || value['_bsontype'] === 'MaxKey') {
4831
- return (name != null ? buffer.Buffer.byteLength(name, 'utf8') + 1 : 0) + 1;
3526
+ return (name != null ? Buffer.byteLength(name, 'utf8') + 1 : 0) + 1;
4832
3527
  }
4833
3528
  else if (value['_bsontype'] === 'ObjectId' || value['_bsontype'] === 'ObjectID') {
4834
- return (name != null ? buffer.Buffer.byteLength(name, 'utf8') + 1 : 0) + (12 + 1);
3529
+ return (name != null ? Buffer.byteLength(name, 'utf8') + 1 : 0) + (12 + 1);
4835
3530
  }
4836
- else if (value instanceof Date || utils.isDate(value)) {
4837
- return (name != null ? buffer.Buffer.byteLength(name, 'utf8') + 1 : 0) + (8 + 1);
3531
+ else if (value instanceof Date || isDate(value)) {
3532
+ return (name != null ? Buffer.byteLength(name, 'utf8') + 1 : 0) + (8 + 1);
4838
3533
  }
4839
3534
  else if (ArrayBuffer.isView(value) ||
4840
3535
  value instanceof ArrayBuffer ||
4841
- utils.isAnyArrayBuffer(value)) {
4842
- return ((name != null ? buffer.Buffer.byteLength(name, 'utf8') + 1 : 0) + (1 + 4 + 1) + value.byteLength);
3536
+ isAnyArrayBuffer(value)) {
3537
+ return ((name != null ? Buffer.byteLength(name, 'utf8') + 1 : 0) + (1 + 4 + 1) + value.byteLength);
4843
3538
  }
4844
3539
  else if (value['_bsontype'] === 'Long' ||
4845
3540
  value['_bsontype'] === 'Double' ||
4846
3541
  value['_bsontype'] === 'Timestamp') {
4847
- return (name != null ? buffer.Buffer.byteLength(name, 'utf8') + 1 : 0) + (8 + 1);
3542
+ return (name != null ? Buffer.byteLength(name, 'utf8') + 1 : 0) + (8 + 1);
4848
3543
  }
4849
3544
  else if (value['_bsontype'] === 'Decimal128') {
4850
- return (name != null ? buffer.Buffer.byteLength(name, 'utf8') + 1 : 0) + (16 + 1);
3545
+ return (name != null ? Buffer.byteLength(name, 'utf8') + 1 : 0) + (16 + 1);
4851
3546
  }
4852
3547
  else if (value['_bsontype'] === 'Code') {
4853
3548
  // Calculate size depending on the availability of a scope
4854
3549
  if (value.scope != null && Object.keys(value.scope).length > 0) {
4855
- return ((name != null ? buffer.Buffer.byteLength(name, 'utf8') + 1 : 0) +
3550
+ return ((name != null ? Buffer.byteLength(name, 'utf8') + 1 : 0) +
4856
3551
  1 +
4857
3552
  4 +
4858
3553
  4 +
4859
- buffer.Buffer.byteLength(value.code.toString(), 'utf8') +
3554
+ Buffer.byteLength(value.code.toString(), 'utf8') +
4860
3555
  1 +
4861
- calculateObjectSize(value.scope, serializeFunctions, ignoreUndefined));
3556
+ calculateObjectSize$1(value.scope, serializeFunctions, ignoreUndefined));
4862
3557
  }
4863
3558
  else {
4864
- return ((name != null ? buffer.Buffer.byteLength(name, 'utf8') + 1 : 0) +
3559
+ return ((name != null ? Buffer.byteLength(name, 'utf8') + 1 : 0) +
4865
3560
  1 +
4866
3561
  4 +
4867
- buffer.Buffer.byteLength(value.code.toString(), 'utf8') +
3562
+ Buffer.byteLength(value.code.toString(), 'utf8') +
4868
3563
  1);
4869
3564
  }
4870
3565
  }
4871
3566
  else if (value['_bsontype'] === 'Binary') {
4872
3567
  // Check what kind of subtype we have
4873
- if (value.sub_type === binary.Binary.SUBTYPE_BYTE_ARRAY) {
4874
- return ((name != null ? buffer.Buffer.byteLength(name, 'utf8') + 1 : 0) +
3568
+ if (value.sub_type === Binary.SUBTYPE_BYTE_ARRAY) {
3569
+ return ((name != null ? Buffer.byteLength(name, 'utf8') + 1 : 0) +
4875
3570
  (value.position + 1 + 4 + 1 + 4));
4876
3571
  }
4877
3572
  else {
4878
- return ((name != null ? buffer.Buffer.byteLength(name, 'utf8') + 1 : 0) + (value.position + 1 + 4 + 1));
3573
+ return ((name != null ? Buffer.byteLength(name, 'utf8') + 1 : 0) + (value.position + 1 + 4 + 1));
4879
3574
  }
4880
3575
  }
4881
3576
  else if (value['_bsontype'] === 'Symbol') {
4882
- return ((name != null ? buffer.Buffer.byteLength(name, 'utf8') + 1 : 0) +
4883
- buffer.Buffer.byteLength(value.value, 'utf8') +
3577
+ return ((name != null ? Buffer.byteLength(name, 'utf8') + 1 : 0) +
3578
+ Buffer.byteLength(value.value, 'utf8') +
4884
3579
  4 +
4885
3580
  1 +
4886
3581
  1);
@@ -4895,14 +3590,14 @@ value, serializeFunctions, isArray, ignoreUndefined) {
4895
3590
  if (value.db != null) {
4896
3591
  ordered_values['$db'] = value.db;
4897
3592
  }
4898
- return ((name != null ? buffer.Buffer.byteLength(name, 'utf8') + 1 : 0) +
3593
+ return ((name != null ? Buffer.byteLength(name, 'utf8') + 1 : 0) +
4899
3594
  1 +
4900
- calculateObjectSize(ordered_values, serializeFunctions, ignoreUndefined));
3595
+ calculateObjectSize$1(ordered_values, serializeFunctions, ignoreUndefined));
4901
3596
  }
4902
- else if (value instanceof RegExp || utils.isRegExp(value)) {
4903
- return ((name != null ? buffer.Buffer.byteLength(name, 'utf8') + 1 : 0) +
3597
+ else if (value instanceof RegExp || isRegExp(value)) {
3598
+ return ((name != null ? Buffer.byteLength(name, 'utf8') + 1 : 0) +
4904
3599
  1 +
4905
- buffer.Buffer.byteLength(value.source, 'utf8') +
3600
+ Buffer.byteLength(value.source, 'utf8') +
4906
3601
  1 +
4907
3602
  (value.global ? 1 : 0) +
4908
3603
  (value.ignoreCase ? 1 : 0) +
@@ -4910,24 +3605,24 @@ value, serializeFunctions, isArray, ignoreUndefined) {
4910
3605
  1);
4911
3606
  }
4912
3607
  else if (value['_bsontype'] === 'BSONRegExp') {
4913
- return ((name != null ? buffer.Buffer.byteLength(name, 'utf8') + 1 : 0) +
3608
+ return ((name != null ? Buffer.byteLength(name, 'utf8') + 1 : 0) +
4914
3609
  1 +
4915
- buffer.Buffer.byteLength(value.pattern, 'utf8') +
3610
+ Buffer.byteLength(value.pattern, 'utf8') +
4916
3611
  1 +
4917
- buffer.Buffer.byteLength(value.options, 'utf8') +
3612
+ Buffer.byteLength(value.options, 'utf8') +
4918
3613
  1);
4919
3614
  }
4920
3615
  else {
4921
- return ((name != null ? buffer.Buffer.byteLength(name, 'utf8') + 1 : 0) +
4922
- calculateObjectSize(value, serializeFunctions, ignoreUndefined) +
3616
+ return ((name != null ? Buffer.byteLength(name, 'utf8') + 1 : 0) +
3617
+ calculateObjectSize$1(value, serializeFunctions, ignoreUndefined) +
4923
3618
  1);
4924
3619
  }
4925
3620
  case 'function':
4926
3621
  // WTF for 0.4.X where typeof /someregexp/ === 'function'
4927
- if (value instanceof RegExp || utils.isRegExp(value) || String.call(value) === '[object RegExp]') {
4928
- return ((name != null ? buffer.Buffer.byteLength(name, 'utf8') + 1 : 0) +
3622
+ if (value instanceof RegExp || isRegExp(value) || String.call(value) === '[object RegExp]') {
3623
+ return ((name != null ? Buffer.byteLength(name, 'utf8') + 1 : 0) +
4929
3624
  1 +
4930
- buffer.Buffer.byteLength(value.source, 'utf8') +
3625
+ Buffer.byteLength(value.source, 'utf8') +
4931
3626
  1 +
4932
3627
  (value.global ? 1 : 0) +
4933
3628
  (value.ignoreCase ? 1 : 0) +
@@ -4936,34 +3631,26 @@ value, serializeFunctions, isArray, ignoreUndefined) {
4936
3631
  }
4937
3632
  else {
4938
3633
  if (serializeFunctions && value.scope != null && Object.keys(value.scope).length > 0) {
4939
- return ((name != null ? buffer.Buffer.byteLength(name, 'utf8') + 1 : 0) +
3634
+ return ((name != null ? Buffer.byteLength(name, 'utf8') + 1 : 0) +
4940
3635
  1 +
4941
3636
  4 +
4942
3637
  4 +
4943
- buffer.Buffer.byteLength(utils.normalizedFunctionString(value), 'utf8') +
3638
+ Buffer.byteLength(normalizedFunctionString(value), 'utf8') +
4944
3639
  1 +
4945
- calculateObjectSize(value.scope, serializeFunctions, ignoreUndefined));
3640
+ calculateObjectSize$1(value.scope, serializeFunctions, ignoreUndefined));
4946
3641
  }
4947
3642
  else if (serializeFunctions) {
4948
- return ((name != null ? buffer.Buffer.byteLength(name, 'utf8') + 1 : 0) +
3643
+ return ((name != null ? Buffer.byteLength(name, 'utf8') + 1 : 0) +
4949
3644
  1 +
4950
3645
  4 +
4951
- buffer.Buffer.byteLength(utils.normalizedFunctionString(value), 'utf8') +
3646
+ Buffer.byteLength(normalizedFunctionString(value), 'utf8') +
4952
3647
  1);
4953
3648
  }
4954
3649
  }
4955
3650
  }
4956
3651
  return 0;
4957
3652
  }
4958
- //# sourceMappingURL=calculate_size.js.map
4959
- });
4960
3653
 
4961
- unwrapExports(calculate_size);
4962
- calculate_size.calculateObjectSize;
4963
-
4964
- var validate_utf8 = createCommonjsModule(function (module, exports) {
4965
- Object.defineProperty(exports, "__esModule", { value: true });
4966
- exports.validateUtf8 = void 0;
4967
3654
  var FIRST_BIT = 0x80;
4968
3655
  var FIRST_TWO_BITS = 0xc0;
4969
3656
  var FIRST_THREE_BITS = 0xe0;
@@ -5006,37 +3693,12 @@ function validateUtf8(bytes, start, end) {
5006
3693
  }
5007
3694
  return !continuation;
5008
3695
  }
5009
- exports.validateUtf8 = validateUtf8;
5010
- //# sourceMappingURL=validate_utf8.js.map
5011
- });
5012
-
5013
- unwrapExports(validate_utf8);
5014
- validate_utf8.validateUtf8;
5015
-
5016
- var deserializer = createCommonjsModule(function (module, exports) {
5017
- Object.defineProperty(exports, "__esModule", { value: true });
5018
- exports.deserialize = void 0;
5019
-
5020
-
5021
-
5022
-
5023
-
5024
-
5025
-
5026
-
5027
-
5028
-
5029
-
5030
-
5031
-
5032
-
5033
-
5034
3696
 
5035
3697
  // Internal long versions
5036
- var JS_INT_MAX_LONG = long_1.Long.fromNumber(constants.JS_INT_MAX);
5037
- var JS_INT_MIN_LONG = long_1.Long.fromNumber(constants.JS_INT_MIN);
3698
+ var JS_INT_MAX_LONG = Long.fromNumber(JS_INT_MAX);
3699
+ var JS_INT_MIN_LONG = Long.fromNumber(JS_INT_MIN);
5038
3700
  var functionCache = {};
5039
- function deserialize(buffer, options, isArray) {
3701
+ function deserialize$1(buffer, options, isArray) {
5040
3702
  options = options == null ? {} : options;
5041
3703
  var index = options && options.index ? options.index : 0;
5042
3704
  // Read the document size
@@ -5063,8 +3725,8 @@ function deserialize(buffer, options, isArray) {
5063
3725
  // Start deserializtion
5064
3726
  return deserializeObject(buffer, index, options, isArray);
5065
3727
  }
5066
- exports.deserialize = deserialize;
5067
- function deserializeObject(buffer$1, index, options, isArray) {
3728
+ var allowedDBRefKeys = /^\$ref$|^\$id$|^\$db$/;
3729
+ function deserializeObject(buffer, index, options, isArray) {
5068
3730
  if (isArray === void 0) { isArray = false; }
5069
3731
  var evalFunctions = options['evalFunctions'] == null ? false : options['evalFunctions'];
5070
3732
  var cacheFunctions = options['cacheFunctions'] == null ? false : options['cacheFunctions'];
@@ -5080,115 +3742,124 @@ function deserializeObject(buffer$1, index, options, isArray) {
5080
3742
  // Set the start index
5081
3743
  var startIndex = index;
5082
3744
  // Validate that we have at least 4 bytes of buffer
5083
- if (buffer$1.length < 5)
3745
+ if (buffer.length < 5)
5084
3746
  throw new Error('corrupt bson message < 5 bytes long');
5085
3747
  // Read the document size
5086
- var size = buffer$1[index++] | (buffer$1[index++] << 8) | (buffer$1[index++] << 16) | (buffer$1[index++] << 24);
3748
+ var size = buffer[index++] | (buffer[index++] << 8) | (buffer[index++] << 16) | (buffer[index++] << 24);
5087
3749
  // Ensure buffer is valid size
5088
- if (size < 5 || size > buffer$1.length)
3750
+ if (size < 5 || size > buffer.length)
5089
3751
  throw new Error('corrupt bson message');
5090
3752
  // Create holding object
5091
3753
  var object = isArray ? [] : {};
5092
3754
  // Used for arrays to skip having to perform utf8 decoding
5093
3755
  var arrayIndex = 0;
5094
3756
  var done = false;
3757
+ var isPossibleDBRef = isArray ? false : null;
5095
3758
  // While we have more left data left keep parsing
5096
3759
  while (!done) {
5097
3760
  // Read the type
5098
- var elementType = buffer$1[index++];
3761
+ var elementType = buffer[index++];
5099
3762
  // If we get a zero it's the last byte, exit
5100
3763
  if (elementType === 0)
5101
3764
  break;
5102
3765
  // Get the start search index
5103
3766
  var i = index;
5104
3767
  // Locate the end of the c string
5105
- while (buffer$1[i] !== 0x00 && i < buffer$1.length) {
3768
+ while (buffer[i] !== 0x00 && i < buffer.length) {
5106
3769
  i++;
5107
3770
  }
5108
3771
  // If are at the end of the buffer there is a problem with the document
5109
- if (i >= buffer$1.byteLength)
3772
+ if (i >= buffer.byteLength)
5110
3773
  throw new Error('Bad BSON Document: illegal CString');
5111
- var name = isArray ? arrayIndex++ : buffer$1.toString('utf8', index, i);
3774
+ var name = isArray ? arrayIndex++ : buffer.toString('utf8', index, i);
3775
+ if (isPossibleDBRef !== false && name[0] === '$') {
3776
+ isPossibleDBRef = allowedDBRefKeys.test(name);
3777
+ }
5112
3778
  var value = void 0;
5113
3779
  index = i + 1;
5114
- if (elementType === constants.BSON_DATA_STRING) {
5115
- var stringSize = buffer$1[index++] |
5116
- (buffer$1[index++] << 8) |
5117
- (buffer$1[index++] << 16) |
5118
- (buffer$1[index++] << 24);
3780
+ if (elementType === BSON_DATA_STRING) {
3781
+ var stringSize = buffer[index++] |
3782
+ (buffer[index++] << 8) |
3783
+ (buffer[index++] << 16) |
3784
+ (buffer[index++] << 24);
5119
3785
  if (stringSize <= 0 ||
5120
- stringSize > buffer$1.length - index ||
5121
- buffer$1[index + stringSize - 1] !== 0)
3786
+ stringSize > buffer.length - index ||
3787
+ buffer[index + stringSize - 1] !== 0)
5122
3788
  throw new Error('bad string length in bson');
5123
- if (!validate_utf8.validateUtf8(buffer$1, index, index + stringSize - 1)) {
5124
- throw new Error('Invalid UTF-8 string in BSON document');
3789
+ value = buffer.toString('utf8', index, index + stringSize - 1);
3790
+ for (var i_1 = 0; i_1 < value.length; i_1++) {
3791
+ if (value.charCodeAt(i_1) === 0xfffd) {
3792
+ if (!validateUtf8(buffer, index, index + stringSize - 1)) {
3793
+ throw new Error('Invalid UTF-8 string in BSON document');
3794
+ }
3795
+ break;
3796
+ }
5125
3797
  }
5126
- value = buffer$1.toString('utf8', index, index + stringSize - 1);
5127
3798
  index = index + stringSize;
5128
3799
  }
5129
- else if (elementType === constants.BSON_DATA_OID) {
5130
- var oid = buffer.Buffer.alloc(12);
5131
- buffer$1.copy(oid, 0, index, index + 12);
5132
- value = new objectid.ObjectId(oid);
3800
+ else if (elementType === BSON_DATA_OID) {
3801
+ var oid = Buffer.alloc(12);
3802
+ buffer.copy(oid, 0, index, index + 12);
3803
+ value = new ObjectId(oid);
5133
3804
  index = index + 12;
5134
3805
  }
5135
- else if (elementType === constants.BSON_DATA_INT && promoteValues === false) {
5136
- value = new int_32.Int32(buffer$1[index++] | (buffer$1[index++] << 8) | (buffer$1[index++] << 16) | (buffer$1[index++] << 24));
3806
+ else if (elementType === BSON_DATA_INT && promoteValues === false) {
3807
+ value = new Int32(buffer[index++] | (buffer[index++] << 8) | (buffer[index++] << 16) | (buffer[index++] << 24));
5137
3808
  }
5138
- else if (elementType === constants.BSON_DATA_INT) {
3809
+ else if (elementType === BSON_DATA_INT) {
5139
3810
  value =
5140
- buffer$1[index++] |
5141
- (buffer$1[index++] << 8) |
5142
- (buffer$1[index++] << 16) |
5143
- (buffer$1[index++] << 24);
3811
+ buffer[index++] |
3812
+ (buffer[index++] << 8) |
3813
+ (buffer[index++] << 16) |
3814
+ (buffer[index++] << 24);
5144
3815
  }
5145
- else if (elementType === constants.BSON_DATA_NUMBER && promoteValues === false) {
5146
- value = new double_1.Double(buffer$1.readDoubleLE(index));
3816
+ else if (elementType === BSON_DATA_NUMBER && promoteValues === false) {
3817
+ value = new Double(buffer.readDoubleLE(index));
5147
3818
  index = index + 8;
5148
3819
  }
5149
- else if (elementType === constants.BSON_DATA_NUMBER) {
5150
- value = buffer$1.readDoubleLE(index);
3820
+ else if (elementType === BSON_DATA_NUMBER) {
3821
+ value = buffer.readDoubleLE(index);
5151
3822
  index = index + 8;
5152
3823
  }
5153
- else if (elementType === constants.BSON_DATA_DATE) {
5154
- var lowBits = buffer$1[index++] |
5155
- (buffer$1[index++] << 8) |
5156
- (buffer$1[index++] << 16) |
5157
- (buffer$1[index++] << 24);
5158
- var highBits = buffer$1[index++] |
5159
- (buffer$1[index++] << 8) |
5160
- (buffer$1[index++] << 16) |
5161
- (buffer$1[index++] << 24);
5162
- value = new Date(new long_1.Long(lowBits, highBits).toNumber());
5163
- }
5164
- else if (elementType === constants.BSON_DATA_BOOLEAN) {
5165
- if (buffer$1[index] !== 0 && buffer$1[index] !== 1)
3824
+ else if (elementType === BSON_DATA_DATE) {
3825
+ var lowBits = buffer[index++] |
3826
+ (buffer[index++] << 8) |
3827
+ (buffer[index++] << 16) |
3828
+ (buffer[index++] << 24);
3829
+ var highBits = buffer[index++] |
3830
+ (buffer[index++] << 8) |
3831
+ (buffer[index++] << 16) |
3832
+ (buffer[index++] << 24);
3833
+ value = new Date(new Long(lowBits, highBits).toNumber());
3834
+ }
3835
+ else if (elementType === BSON_DATA_BOOLEAN) {
3836
+ if (buffer[index] !== 0 && buffer[index] !== 1)
5166
3837
  throw new Error('illegal boolean type value');
5167
- value = buffer$1[index++] === 1;
3838
+ value = buffer[index++] === 1;
5168
3839
  }
5169
- else if (elementType === constants.BSON_DATA_OBJECT) {
3840
+ else if (elementType === BSON_DATA_OBJECT) {
5170
3841
  var _index = index;
5171
- var objectSize = buffer$1[index] |
5172
- (buffer$1[index + 1] << 8) |
5173
- (buffer$1[index + 2] << 16) |
5174
- (buffer$1[index + 3] << 24);
5175
- if (objectSize <= 0 || objectSize > buffer$1.length - index)
3842
+ var objectSize = buffer[index] |
3843
+ (buffer[index + 1] << 8) |
3844
+ (buffer[index + 2] << 16) |
3845
+ (buffer[index + 3] << 24);
3846
+ if (objectSize <= 0 || objectSize > buffer.length - index)
5176
3847
  throw new Error('bad embedded document length in bson');
5177
3848
  // We have a raw value
5178
3849
  if (raw) {
5179
- value = buffer$1.slice(index, index + objectSize);
3850
+ value = buffer.slice(index, index + objectSize);
5180
3851
  }
5181
3852
  else {
5182
- value = deserializeObject(buffer$1, _index, options, false);
3853
+ value = deserializeObject(buffer, _index, options, false);
5183
3854
  }
5184
3855
  index = index + objectSize;
5185
3856
  }
5186
- else if (elementType === constants.BSON_DATA_ARRAY) {
3857
+ else if (elementType === BSON_DATA_ARRAY) {
5187
3858
  var _index = index;
5188
- var objectSize = buffer$1[index] |
5189
- (buffer$1[index + 1] << 8) |
5190
- (buffer$1[index + 2] << 16) |
5191
- (buffer$1[index + 3] << 24);
3859
+ var objectSize = buffer[index] |
3860
+ (buffer[index + 1] << 8) |
3861
+ (buffer[index + 2] << 16) |
3862
+ (buffer[index + 3] << 24);
5192
3863
  var arrayOptions = options;
5193
3864
  // Stop index
5194
3865
  var stopIndex = index + objectSize;
@@ -5200,30 +3871,30 @@ function deserializeObject(buffer$1, index, options, isArray) {
5200
3871
  }
5201
3872
  arrayOptions['raw'] = true;
5202
3873
  }
5203
- value = deserializeObject(buffer$1, _index, arrayOptions, true);
3874
+ value = deserializeObject(buffer, _index, arrayOptions, true);
5204
3875
  index = index + objectSize;
5205
- if (buffer$1[index - 1] !== 0)
3876
+ if (buffer[index - 1] !== 0)
5206
3877
  throw new Error('invalid array terminator byte');
5207
3878
  if (index !== stopIndex)
5208
3879
  throw new Error('corrupted array bson');
5209
3880
  }
5210
- else if (elementType === constants.BSON_DATA_UNDEFINED) {
3881
+ else if (elementType === BSON_DATA_UNDEFINED) {
5211
3882
  value = undefined;
5212
3883
  }
5213
- else if (elementType === constants.BSON_DATA_NULL) {
3884
+ else if (elementType === BSON_DATA_NULL) {
5214
3885
  value = null;
5215
3886
  }
5216
- else if (elementType === constants.BSON_DATA_LONG) {
3887
+ else if (elementType === BSON_DATA_LONG) {
5217
3888
  // Unpack the low and high bits
5218
- var lowBits = buffer$1[index++] |
5219
- (buffer$1[index++] << 8) |
5220
- (buffer$1[index++] << 16) |
5221
- (buffer$1[index++] << 24);
5222
- var highBits = buffer$1[index++] |
5223
- (buffer$1[index++] << 8) |
5224
- (buffer$1[index++] << 16) |
5225
- (buffer$1[index++] << 24);
5226
- var long = new long_1.Long(lowBits, highBits);
3889
+ var lowBits = buffer[index++] |
3890
+ (buffer[index++] << 8) |
3891
+ (buffer[index++] << 16) |
3892
+ (buffer[index++] << 24);
3893
+ var highBits = buffer[index++] |
3894
+ (buffer[index++] << 8) |
3895
+ (buffer[index++] << 16) |
3896
+ (buffer[index++] << 24);
3897
+ var long = new Long(lowBits, highBits);
5227
3898
  // Promote the long if possible
5228
3899
  if (promoteLongs && promoteValues === true) {
5229
3900
  value =
@@ -5235,45 +3906,45 @@ function deserializeObject(buffer$1, index, options, isArray) {
5235
3906
  value = long;
5236
3907
  }
5237
3908
  }
5238
- else if (elementType === constants.BSON_DATA_DECIMAL128) {
3909
+ else if (elementType === BSON_DATA_DECIMAL128) {
5239
3910
  // Buffer to contain the decimal bytes
5240
- var bytes = buffer.Buffer.alloc(16);
3911
+ var bytes = Buffer.alloc(16);
5241
3912
  // Copy the next 16 bytes into the bytes buffer
5242
- buffer$1.copy(bytes, 0, index, index + 16);
3913
+ buffer.copy(bytes, 0, index, index + 16);
5243
3914
  // Update index
5244
3915
  index = index + 16;
5245
3916
  // Assign the new Decimal128 value
5246
- var decimal128$1 = new decimal128.Decimal128(bytes);
3917
+ var decimal128 = new Decimal128(bytes);
5247
3918
  // If we have an alternative mapper use that
5248
- if ('toObject' in decimal128$1 && typeof decimal128$1.toObject === 'function') {
5249
- value = decimal128$1.toObject();
3919
+ if ('toObject' in decimal128 && typeof decimal128.toObject === 'function') {
3920
+ value = decimal128.toObject();
5250
3921
  }
5251
3922
  else {
5252
- value = decimal128$1;
3923
+ value = decimal128;
5253
3924
  }
5254
3925
  }
5255
- else if (elementType === constants.BSON_DATA_BINARY) {
5256
- var binarySize = buffer$1[index++] |
5257
- (buffer$1[index++] << 8) |
5258
- (buffer$1[index++] << 16) |
5259
- (buffer$1[index++] << 24);
3926
+ else if (elementType === BSON_DATA_BINARY) {
3927
+ var binarySize = buffer[index++] |
3928
+ (buffer[index++] << 8) |
3929
+ (buffer[index++] << 16) |
3930
+ (buffer[index++] << 24);
5260
3931
  var totalBinarySize = binarySize;
5261
- var subType = buffer$1[index++];
3932
+ var subType = buffer[index++];
5262
3933
  // Did we have a negative binary size, throw
5263
3934
  if (binarySize < 0)
5264
3935
  throw new Error('Negative binary type element size found');
5265
3936
  // Is the length longer than the document
5266
- if (binarySize > buffer$1.byteLength)
3937
+ if (binarySize > buffer.byteLength)
5267
3938
  throw new Error('Binary type size larger than document size');
5268
3939
  // Decode as raw Buffer object if options specifies it
5269
- if (buffer$1['slice'] != null) {
3940
+ if (buffer['slice'] != null) {
5270
3941
  // If we have subtype 2 skip the 4 bytes for the size
5271
- if (subType === binary.Binary.SUBTYPE_BYTE_ARRAY) {
3942
+ if (subType === Binary.SUBTYPE_BYTE_ARRAY) {
5272
3943
  binarySize =
5273
- buffer$1[index++] |
5274
- (buffer$1[index++] << 8) |
5275
- (buffer$1[index++] << 16) |
5276
- (buffer$1[index++] << 24);
3944
+ buffer[index++] |
3945
+ (buffer[index++] << 8) |
3946
+ (buffer[index++] << 16) |
3947
+ (buffer[index++] << 24);
5277
3948
  if (binarySize < 0)
5278
3949
  throw new Error('Negative binary type element size found for subtype 0x02');
5279
3950
  if (binarySize > totalBinarySize - 4)
@@ -5282,21 +3953,21 @@ function deserializeObject(buffer$1, index, options, isArray) {
5282
3953
  throw new Error('Binary type with subtype 0x02 contains too short binary size');
5283
3954
  }
5284
3955
  if (promoteBuffers && promoteValues) {
5285
- value = buffer$1.slice(index, index + binarySize);
3956
+ value = buffer.slice(index, index + binarySize);
5286
3957
  }
5287
3958
  else {
5288
- value = new binary.Binary(buffer$1.slice(index, index + binarySize), subType);
3959
+ value = new Binary(buffer.slice(index, index + binarySize), subType);
5289
3960
  }
5290
3961
  }
5291
3962
  else {
5292
- var _buffer = buffer.Buffer.alloc(binarySize);
3963
+ var _buffer = Buffer.alloc(binarySize);
5293
3964
  // If we have subtype 2 skip the 4 bytes for the size
5294
- if (subType === binary.Binary.SUBTYPE_BYTE_ARRAY) {
3965
+ if (subType === Binary.SUBTYPE_BYTE_ARRAY) {
5295
3966
  binarySize =
5296
- buffer$1[index++] |
5297
- (buffer$1[index++] << 8) |
5298
- (buffer$1[index++] << 16) |
5299
- (buffer$1[index++] << 24);
3967
+ buffer[index++] |
3968
+ (buffer[index++] << 8) |
3969
+ (buffer[index++] << 16) |
3970
+ (buffer[index++] << 24);
5300
3971
  if (binarySize < 0)
5301
3972
  throw new Error('Negative binary type element size found for subtype 0x02');
5302
3973
  if (binarySize > totalBinarySize - 4)
@@ -5306,43 +3977,43 @@ function deserializeObject(buffer$1, index, options, isArray) {
5306
3977
  }
5307
3978
  // Copy the data
5308
3979
  for (i = 0; i < binarySize; i++) {
5309
- _buffer[i] = buffer$1[index + i];
3980
+ _buffer[i] = buffer[index + i];
5310
3981
  }
5311
3982
  if (promoteBuffers && promoteValues) {
5312
3983
  value = _buffer;
5313
3984
  }
5314
3985
  else {
5315
- value = new binary.Binary(_buffer, subType);
3986
+ value = new Binary(_buffer, subType);
5316
3987
  }
5317
3988
  }
5318
3989
  // Update the index
5319
3990
  index = index + binarySize;
5320
3991
  }
5321
- else if (elementType === constants.BSON_DATA_REGEXP && bsonRegExp === false) {
3992
+ else if (elementType === BSON_DATA_REGEXP && bsonRegExp === false) {
5322
3993
  // Get the start search index
5323
3994
  i = index;
5324
3995
  // Locate the end of the c string
5325
- while (buffer$1[i] !== 0x00 && i < buffer$1.length) {
3996
+ while (buffer[i] !== 0x00 && i < buffer.length) {
5326
3997
  i++;
5327
3998
  }
5328
3999
  // If are at the end of the buffer there is a problem with the document
5329
- if (i >= buffer$1.length)
4000
+ if (i >= buffer.length)
5330
4001
  throw new Error('Bad BSON Document: illegal CString');
5331
4002
  // Return the C string
5332
- var source = buffer$1.toString('utf8', index, i);
4003
+ var source = buffer.toString('utf8', index, i);
5333
4004
  // Create the regexp
5334
4005
  index = i + 1;
5335
4006
  // Get the start search index
5336
4007
  i = index;
5337
4008
  // Locate the end of the c string
5338
- while (buffer$1[i] !== 0x00 && i < buffer$1.length) {
4009
+ while (buffer[i] !== 0x00 && i < buffer.length) {
5339
4010
  i++;
5340
4011
  }
5341
4012
  // If are at the end of the buffer there is a problem with the document
5342
- if (i >= buffer$1.length)
4013
+ if (i >= buffer.length)
5343
4014
  throw new Error('Bad BSON Document: illegal CString');
5344
4015
  // Return the C string
5345
- var regExpOptions = buffer$1.toString('utf8', index, i);
4016
+ var regExpOptions = buffer.toString('utf8', index, i);
5346
4017
  index = i + 1;
5347
4018
  // For each option add the corresponding one for javascript
5348
4019
  var optionsArray = new Array(regExpOptions.length);
@@ -5362,74 +4033,74 @@ function deserializeObject(buffer$1, index, options, isArray) {
5362
4033
  }
5363
4034
  value = new RegExp(source, optionsArray.join(''));
5364
4035
  }
5365
- else if (elementType === constants.BSON_DATA_REGEXP && bsonRegExp === true) {
4036
+ else if (elementType === BSON_DATA_REGEXP && bsonRegExp === true) {
5366
4037
  // Get the start search index
5367
4038
  i = index;
5368
4039
  // Locate the end of the c string
5369
- while (buffer$1[i] !== 0x00 && i < buffer$1.length) {
4040
+ while (buffer[i] !== 0x00 && i < buffer.length) {
5370
4041
  i++;
5371
4042
  }
5372
4043
  // If are at the end of the buffer there is a problem with the document
5373
- if (i >= buffer$1.length)
4044
+ if (i >= buffer.length)
5374
4045
  throw new Error('Bad BSON Document: illegal CString');
5375
4046
  // Return the C string
5376
- var source = buffer$1.toString('utf8', index, i);
4047
+ var source = buffer.toString('utf8', index, i);
5377
4048
  index = i + 1;
5378
4049
  // Get the start search index
5379
4050
  i = index;
5380
4051
  // Locate the end of the c string
5381
- while (buffer$1[i] !== 0x00 && i < buffer$1.length) {
4052
+ while (buffer[i] !== 0x00 && i < buffer.length) {
5382
4053
  i++;
5383
4054
  }
5384
4055
  // If are at the end of the buffer there is a problem with the document
5385
- if (i >= buffer$1.length)
4056
+ if (i >= buffer.length)
5386
4057
  throw new Error('Bad BSON Document: illegal CString');
5387
4058
  // Return the C string
5388
- var regExpOptions = buffer$1.toString('utf8', index, i);
4059
+ var regExpOptions = buffer.toString('utf8', index, i);
5389
4060
  index = i + 1;
5390
4061
  // Set the object
5391
- value = new regexp.BSONRegExp(source, regExpOptions);
4062
+ value = new BSONRegExp(source, regExpOptions);
5392
4063
  }
5393
- else if (elementType === constants.BSON_DATA_SYMBOL) {
5394
- var stringSize = buffer$1[index++] |
5395
- (buffer$1[index++] << 8) |
5396
- (buffer$1[index++] << 16) |
5397
- (buffer$1[index++] << 24);
4064
+ else if (elementType === BSON_DATA_SYMBOL) {
4065
+ var stringSize = buffer[index++] |
4066
+ (buffer[index++] << 8) |
4067
+ (buffer[index++] << 16) |
4068
+ (buffer[index++] << 24);
5398
4069
  if (stringSize <= 0 ||
5399
- stringSize > buffer$1.length - index ||
5400
- buffer$1[index + stringSize - 1] !== 0)
4070
+ stringSize > buffer.length - index ||
4071
+ buffer[index + stringSize - 1] !== 0)
5401
4072
  throw new Error('bad string length in bson');
5402
- var symbol$1 = buffer$1.toString('utf8', index, index + stringSize - 1);
5403
- value = promoteValues ? symbol$1 : new symbol.BSONSymbol(symbol$1);
4073
+ var symbol = buffer.toString('utf8', index, index + stringSize - 1);
4074
+ value = promoteValues ? symbol : new BSONSymbol(symbol);
5404
4075
  index = index + stringSize;
5405
4076
  }
5406
- else if (elementType === constants.BSON_DATA_TIMESTAMP) {
5407
- var lowBits = buffer$1[index++] |
5408
- (buffer$1[index++] << 8) |
5409
- (buffer$1[index++] << 16) |
5410
- (buffer$1[index++] << 24);
5411
- var highBits = buffer$1[index++] |
5412
- (buffer$1[index++] << 8) |
5413
- (buffer$1[index++] << 16) |
5414
- (buffer$1[index++] << 24);
5415
- value = new timestamp.Timestamp(lowBits, highBits);
5416
- }
5417
- else if (elementType === constants.BSON_DATA_MIN_KEY) {
5418
- value = new min_key.MinKey();
5419
- }
5420
- else if (elementType === constants.BSON_DATA_MAX_KEY) {
5421
- value = new max_key.MaxKey();
5422
- }
5423
- else if (elementType === constants.BSON_DATA_CODE) {
5424
- var stringSize = buffer$1[index++] |
5425
- (buffer$1[index++] << 8) |
5426
- (buffer$1[index++] << 16) |
5427
- (buffer$1[index++] << 24);
4077
+ else if (elementType === BSON_DATA_TIMESTAMP) {
4078
+ var lowBits = buffer[index++] |
4079
+ (buffer[index++] << 8) |
4080
+ (buffer[index++] << 16) |
4081
+ (buffer[index++] << 24);
4082
+ var highBits = buffer[index++] |
4083
+ (buffer[index++] << 8) |
4084
+ (buffer[index++] << 16) |
4085
+ (buffer[index++] << 24);
4086
+ value = new Timestamp(lowBits, highBits);
4087
+ }
4088
+ else if (elementType === BSON_DATA_MIN_KEY) {
4089
+ value = new MinKey();
4090
+ }
4091
+ else if (elementType === BSON_DATA_MAX_KEY) {
4092
+ value = new MaxKey();
4093
+ }
4094
+ else if (elementType === BSON_DATA_CODE) {
4095
+ var stringSize = buffer[index++] |
4096
+ (buffer[index++] << 8) |
4097
+ (buffer[index++] << 16) |
4098
+ (buffer[index++] << 24);
5428
4099
  if (stringSize <= 0 ||
5429
- stringSize > buffer$1.length - index ||
5430
- buffer$1[index + stringSize - 1] !== 0)
4100
+ stringSize > buffer.length - index ||
4101
+ buffer[index + stringSize - 1] !== 0)
5431
4102
  throw new Error('bad string length in bson');
5432
- var functionString = buffer$1.toString('utf8', index, index + stringSize - 1);
4103
+ var functionString = buffer.toString('utf8', index, index + stringSize - 1);
5433
4104
  // If we are evaluating the functions
5434
4105
  if (evalFunctions) {
5435
4106
  // If we have cache enabled let's look for the md5 of the function in the cache
@@ -5442,43 +4113,43 @@ function deserializeObject(buffer$1, index, options, isArray) {
5442
4113
  }
5443
4114
  }
5444
4115
  else {
5445
- value = new code.Code(functionString);
4116
+ value = new Code(functionString);
5446
4117
  }
5447
4118
  // Update parse index position
5448
4119
  index = index + stringSize;
5449
4120
  }
5450
- else if (elementType === constants.BSON_DATA_CODE_W_SCOPE) {
5451
- var totalSize = buffer$1[index++] |
5452
- (buffer$1[index++] << 8) |
5453
- (buffer$1[index++] << 16) |
5454
- (buffer$1[index++] << 24);
4121
+ else if (elementType === BSON_DATA_CODE_W_SCOPE) {
4122
+ var totalSize = buffer[index++] |
4123
+ (buffer[index++] << 8) |
4124
+ (buffer[index++] << 16) |
4125
+ (buffer[index++] << 24);
5455
4126
  // Element cannot be shorter than totalSize + stringSize + documentSize + terminator
5456
4127
  if (totalSize < 4 + 4 + 4 + 1) {
5457
4128
  throw new Error('code_w_scope total size shorter minimum expected length');
5458
4129
  }
5459
4130
  // Get the code string size
5460
- var stringSize = buffer$1[index++] |
5461
- (buffer$1[index++] << 8) |
5462
- (buffer$1[index++] << 16) |
5463
- (buffer$1[index++] << 24);
4131
+ var stringSize = buffer[index++] |
4132
+ (buffer[index++] << 8) |
4133
+ (buffer[index++] << 16) |
4134
+ (buffer[index++] << 24);
5464
4135
  // Check if we have a valid string
5465
4136
  if (stringSize <= 0 ||
5466
- stringSize > buffer$1.length - index ||
5467
- buffer$1[index + stringSize - 1] !== 0)
4137
+ stringSize > buffer.length - index ||
4138
+ buffer[index + stringSize - 1] !== 0)
5468
4139
  throw new Error('bad string length in bson');
5469
4140
  // Javascript function
5470
- var functionString = buffer$1.toString('utf8', index, index + stringSize - 1);
4141
+ var functionString = buffer.toString('utf8', index, index + stringSize - 1);
5471
4142
  // Update parse index position
5472
4143
  index = index + stringSize;
5473
4144
  // Parse the element
5474
4145
  var _index = index;
5475
4146
  // Decode the size of the object document
5476
- var objectSize = buffer$1[index] |
5477
- (buffer$1[index + 1] << 8) |
5478
- (buffer$1[index + 2] << 16) |
5479
- (buffer$1[index + 3] << 24);
4147
+ var objectSize = buffer[index] |
4148
+ (buffer[index + 1] << 8) |
4149
+ (buffer[index + 2] << 16) |
4150
+ (buffer[index + 3] << 24);
5480
4151
  // Decode the scope object
5481
- var scopeObject = deserializeObject(buffer$1, _index, options, false);
4152
+ var scopeObject = deserializeObject(buffer, _index, options, false);
5482
4153
  // Adjust the index
5483
4154
  index = index + objectSize;
5484
4155
  // Check if field length is too short
@@ -5502,35 +4173,35 @@ function deserializeObject(buffer$1, index, options, isArray) {
5502
4173
  value.scope = scopeObject;
5503
4174
  }
5504
4175
  else {
5505
- value = new code.Code(functionString, scopeObject);
4176
+ value = new Code(functionString, scopeObject);
5506
4177
  }
5507
4178
  }
5508
- else if (elementType === constants.BSON_DATA_DBPOINTER) {
4179
+ else if (elementType === BSON_DATA_DBPOINTER) {
5509
4180
  // Get the code string size
5510
- var stringSize = buffer$1[index++] |
5511
- (buffer$1[index++] << 8) |
5512
- (buffer$1[index++] << 16) |
5513
- (buffer$1[index++] << 24);
4181
+ var stringSize = buffer[index++] |
4182
+ (buffer[index++] << 8) |
4183
+ (buffer[index++] << 16) |
4184
+ (buffer[index++] << 24);
5514
4185
  // Check if we have a valid string
5515
4186
  if (stringSize <= 0 ||
5516
- stringSize > buffer$1.length - index ||
5517
- buffer$1[index + stringSize - 1] !== 0)
4187
+ stringSize > buffer.length - index ||
4188
+ buffer[index + stringSize - 1] !== 0)
5518
4189
  throw new Error('bad string length in bson');
5519
4190
  // Namespace
5520
- if (!validate_utf8.validateUtf8(buffer$1, index, index + stringSize - 1)) {
4191
+ if (!validateUtf8(buffer, index, index + stringSize - 1)) {
5521
4192
  throw new Error('Invalid UTF-8 string in BSON document');
5522
4193
  }
5523
- var namespace = buffer$1.toString('utf8', index, index + stringSize - 1);
4194
+ var namespace = buffer.toString('utf8', index, index + stringSize - 1);
5524
4195
  // Update parse index position
5525
4196
  index = index + stringSize;
5526
4197
  // Read the oid
5527
- var oidBuffer = buffer.Buffer.alloc(12);
5528
- buffer$1.copy(oidBuffer, 0, index, index + 12);
5529
- var oid = new objectid.ObjectId(oidBuffer);
4198
+ var oidBuffer = Buffer.alloc(12);
4199
+ buffer.copy(oidBuffer, 0, index, index + 12);
4200
+ var oid = new ObjectId(oidBuffer);
5530
4201
  // Update the index
5531
4202
  index = index + 12;
5532
4203
  // Upgrade to DBRef type
5533
- value = new db_ref.DBRef(namespace, oid);
4204
+ value = new DBRef(namespace, oid);
5534
4205
  }
5535
4206
  else {
5536
4207
  throw new Error('Detected unknown BSON type ' + elementType.toString(16) + ' for fieldname "' + name + '"');
@@ -5553,22 +4224,15 @@ function deserializeObject(buffer$1, index, options, isArray) {
5553
4224
  throw new Error('corrupt array bson');
5554
4225
  throw new Error('corrupt object bson');
5555
4226
  }
5556
- // check if object's $ keys are those of a DBRef
5557
- var dollarKeys = Object.keys(object).filter(function (k) { return k.startsWith('$'); });
5558
- var valid = true;
5559
- dollarKeys.forEach(function (k) {
5560
- if (['$ref', '$id', '$db'].indexOf(k) === -1)
5561
- valid = false;
5562
- });
5563
- // if a $key not in "$ref", "$id", "$db", don't make a DBRef
5564
- if (!valid)
4227
+ // if we did not find "$ref", "$id", "$db", or found an extraneous $key, don't make a DBRef
4228
+ if (!isPossibleDBRef)
5565
4229
  return object;
5566
- if (db_ref.isDBRefLike(object)) {
4230
+ if (isDBRefLike(object)) {
5567
4231
  var copy = Object.assign({}, object);
5568
4232
  delete copy.$ref;
5569
4233
  delete copy.$id;
5570
4234
  delete copy.$db;
5571
- return new db_ref.DBRef(object.$ref, object.$id, object.$db, copy);
4235
+ return new DBRef(object.$ref, object.$id, object.$db, copy);
5572
4236
  }
5573
4237
  return object;
5574
4238
  }
@@ -5587,81 +4251,8 @@ function isolateEval(functionString, functionCache, object) {
5587
4251
  // Set the object
5588
4252
  return functionCache[functionString].bind(object);
5589
4253
  }
5590
- //# sourceMappingURL=deserializer.js.map
5591
- });
5592
4254
 
5593
- unwrapExports(deserializer);
5594
- deserializer.deserialize;
5595
-
5596
- var float_parser = createCommonjsModule(function (module, exports) {
5597
4255
  // Copyright (c) 2008, Fair Oaks Labs, Inc.
5598
- // All rights reserved.
5599
- //
5600
- // Redistribution and use in source and binary forms, with or without
5601
- // modification, are permitted provided that the following conditions are met:
5602
- //
5603
- // * Redistributions of source code must retain the above copyright notice,
5604
- // this list of conditions and the following disclaimer.
5605
- //
5606
- // * Redistributions in binary form must reproduce the above copyright notice,
5607
- // this list of conditions and the following disclaimer in the documentation
5608
- // and/or other materials provided with the distribution.
5609
- //
5610
- // * Neither the name of Fair Oaks Labs, Inc. nor the names of its contributors
5611
- // may be used to endorse or promote products derived from this software
5612
- // without specific prior written permission.
5613
- //
5614
- // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
5615
- // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
5616
- // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
5617
- // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
5618
- // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
5619
- // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
5620
- // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
5621
- // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
5622
- // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
5623
- // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
5624
- // POSSIBILITY OF SUCH DAMAGE.
5625
- //
5626
- //
5627
- // Modifications to writeIEEE754 to support negative zeroes made by Brian White
5628
- Object.defineProperty(exports, "__esModule", { value: true });
5629
- exports.writeIEEE754 = exports.readIEEE754 = void 0;
5630
- function readIEEE754(buffer, offset, endian, mLen, nBytes) {
5631
- var e;
5632
- var m;
5633
- var bBE = endian === 'big';
5634
- var eLen = nBytes * 8 - mLen - 1;
5635
- var eMax = (1 << eLen) - 1;
5636
- var eBias = eMax >> 1;
5637
- var nBits = -7;
5638
- var i = bBE ? 0 : nBytes - 1;
5639
- var d = bBE ? 1 : -1;
5640
- var s = buffer[offset + i];
5641
- i += d;
5642
- e = s & ((1 << -nBits) - 1);
5643
- s >>= -nBits;
5644
- nBits += eLen;
5645
- for (; nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8)
5646
- ;
5647
- m = e & ((1 << -nBits) - 1);
5648
- e >>= -nBits;
5649
- nBits += mLen;
5650
- for (; nBits > 0; m = m * 256 + buffer[offset + i], i += d, nBits -= 8)
5651
- ;
5652
- if (e === 0) {
5653
- e = 1 - eBias;
5654
- }
5655
- else if (e === eMax) {
5656
- return m ? NaN : (s ? -1 : 1) * Infinity;
5657
- }
5658
- else {
5659
- m = m + Math.pow(2, mLen);
5660
- e = e - eBias;
5661
- }
5662
- return (s ? -1 : 1) * m * Math.pow(2, e - mLen);
5663
- }
5664
- exports.readIEEE754 = readIEEE754;
5665
4256
  function writeIEEE754(buffer, value, offset, endian, mLen, nBytes) {
5666
4257
  var e;
5667
4258
  var m;
@@ -5728,24 +4319,6 @@ function writeIEEE754(buffer, value, offset, endian, mLen, nBytes) {
5728
4319
  }
5729
4320
  buffer[offset + i - d] |= s * 128;
5730
4321
  }
5731
- exports.writeIEEE754 = writeIEEE754;
5732
- //# sourceMappingURL=float_parser.js.map
5733
- });
5734
-
5735
- unwrapExports(float_parser);
5736
- float_parser.writeIEEE754;
5737
- float_parser.readIEEE754;
5738
-
5739
- var serializer = createCommonjsModule(function (module, exports) {
5740
- Object.defineProperty(exports, "__esModule", { value: true });
5741
- exports.serializeInto = void 0;
5742
-
5743
-
5744
-
5745
-
5746
-
5747
-
5748
-
5749
4322
 
5750
4323
  var regexp = /\x00/; // eslint-disable-line no-control-regex
5751
4324
  var ignoreKeys = new Set(['$db', '$ref', '$id', '$clusterTime']);
@@ -5756,7 +4329,7 @@ var ignoreKeys = new Set(['$db', '$ref', '$id', '$clusterTime']);
5756
4329
  */
5757
4330
  function serializeString(buffer, key, value, index, isArray) {
5758
4331
  // Encode String type
5759
- buffer[index++] = constants.BSON_DATA_STRING;
4332
+ buffer[index++] = BSON_DATA_STRING;
5760
4333
  // Number of written bytes
5761
4334
  var numberOfWrittenBytes = !isArray
5762
4335
  ? buffer.write(key, index, undefined, 'utf8')
@@ -5781,11 +4354,11 @@ function serializeNumber(buffer, key, value, index, isArray) {
5781
4354
  // We have an integer value
5782
4355
  // TODO(NODE-2529): Add support for big int
5783
4356
  if (Number.isInteger(value) &&
5784
- value >= constants.BSON_INT32_MIN &&
5785
- value <= constants.BSON_INT32_MAX) {
4357
+ value >= BSON_INT32_MIN &&
4358
+ value <= BSON_INT32_MAX) {
5786
4359
  // If the value fits in 32 bits encode as int32
5787
4360
  // Set int type 32 bits or less
5788
- buffer[index++] = constants.BSON_DATA_INT;
4361
+ buffer[index++] = BSON_DATA_INT;
5789
4362
  // Number of written bytes
5790
4363
  var numberOfWrittenBytes = !isArray
5791
4364
  ? buffer.write(key, index, undefined, 'utf8')
@@ -5801,7 +4374,7 @@ function serializeNumber(buffer, key, value, index, isArray) {
5801
4374
  }
5802
4375
  else {
5803
4376
  // Encode as double
5804
- buffer[index++] = constants.BSON_DATA_NUMBER;
4377
+ buffer[index++] = BSON_DATA_NUMBER;
5805
4378
  // Number of written bytes
5806
4379
  var numberOfWrittenBytes = !isArray
5807
4380
  ? buffer.write(key, index, undefined, 'utf8')
@@ -5810,7 +4383,7 @@ function serializeNumber(buffer, key, value, index, isArray) {
5810
4383
  index = index + numberOfWrittenBytes;
5811
4384
  buffer[index++] = 0;
5812
4385
  // Write float
5813
- float_parser.writeIEEE754(buffer, value, index, 'little', 52, 8);
4386
+ writeIEEE754(buffer, value, index, 'little', 52, 8);
5814
4387
  // Adjust index
5815
4388
  index = index + 8;
5816
4389
  }
@@ -5818,7 +4391,7 @@ function serializeNumber(buffer, key, value, index, isArray) {
5818
4391
  }
5819
4392
  function serializeNull(buffer, key, _, index, isArray) {
5820
4393
  // Set long type
5821
- buffer[index++] = constants.BSON_DATA_NULL;
4394
+ buffer[index++] = BSON_DATA_NULL;
5822
4395
  // Number of written bytes
5823
4396
  var numberOfWrittenBytes = !isArray
5824
4397
  ? buffer.write(key, index, undefined, 'utf8')
@@ -5830,7 +4403,7 @@ function serializeNull(buffer, key, _, index, isArray) {
5830
4403
  }
5831
4404
  function serializeBoolean(buffer, key, value, index, isArray) {
5832
4405
  // Write the type
5833
- buffer[index++] = constants.BSON_DATA_BOOLEAN;
4406
+ buffer[index++] = BSON_DATA_BOOLEAN;
5834
4407
  // Number of written bytes
5835
4408
  var numberOfWrittenBytes = !isArray
5836
4409
  ? buffer.write(key, index, undefined, 'utf8')
@@ -5844,7 +4417,7 @@ function serializeBoolean(buffer, key, value, index, isArray) {
5844
4417
  }
5845
4418
  function serializeDate(buffer, key, value, index, isArray) {
5846
4419
  // Write the type
5847
- buffer[index++] = constants.BSON_DATA_DATE;
4420
+ buffer[index++] = BSON_DATA_DATE;
5848
4421
  // Number of written bytes
5849
4422
  var numberOfWrittenBytes = !isArray
5850
4423
  ? buffer.write(key, index, undefined, 'utf8')
@@ -5853,7 +4426,7 @@ function serializeDate(buffer, key, value, index, isArray) {
5853
4426
  index = index + numberOfWrittenBytes;
5854
4427
  buffer[index++] = 0;
5855
4428
  // Write the date
5856
- var dateInMilis = long_1.Long.fromNumber(value.getTime());
4429
+ var dateInMilis = Long.fromNumber(value.getTime());
5857
4430
  var lowBits = dateInMilis.getLowBits();
5858
4431
  var highBits = dateInMilis.getHighBits();
5859
4432
  // Encode low bits
@@ -5870,7 +4443,7 @@ function serializeDate(buffer, key, value, index, isArray) {
5870
4443
  }
5871
4444
  function serializeRegExp(buffer, key, value, index, isArray) {
5872
4445
  // Write the type
5873
- buffer[index++] = constants.BSON_DATA_REGEXP;
4446
+ buffer[index++] = BSON_DATA_REGEXP;
5874
4447
  // Number of written bytes
5875
4448
  var numberOfWrittenBytes = !isArray
5876
4449
  ? buffer.write(key, index, undefined, 'utf8')
@@ -5898,7 +4471,7 @@ function serializeRegExp(buffer, key, value, index, isArray) {
5898
4471
  }
5899
4472
  function serializeBSONRegExp(buffer, key, value, index, isArray) {
5900
4473
  // Write the type
5901
- buffer[index++] = constants.BSON_DATA_REGEXP;
4474
+ buffer[index++] = BSON_DATA_REGEXP;
5902
4475
  // Number of written bytes
5903
4476
  var numberOfWrittenBytes = !isArray
5904
4477
  ? buffer.write(key, index, undefined, 'utf8')
@@ -5925,13 +4498,13 @@ function serializeBSONRegExp(buffer, key, value, index, isArray) {
5925
4498
  function serializeMinMax(buffer, key, value, index, isArray) {
5926
4499
  // Write the type of either min or max key
5927
4500
  if (value === null) {
5928
- buffer[index++] = constants.BSON_DATA_NULL;
4501
+ buffer[index++] = BSON_DATA_NULL;
5929
4502
  }
5930
4503
  else if (value._bsontype === 'MinKey') {
5931
- buffer[index++] = constants.BSON_DATA_MIN_KEY;
4504
+ buffer[index++] = BSON_DATA_MIN_KEY;
5932
4505
  }
5933
4506
  else {
5934
- buffer[index++] = constants.BSON_DATA_MAX_KEY;
4507
+ buffer[index++] = BSON_DATA_MAX_KEY;
5935
4508
  }
5936
4509
  // Number of written bytes
5937
4510
  var numberOfWrittenBytes = !isArray
@@ -5944,7 +4517,7 @@ function serializeMinMax(buffer, key, value, index, isArray) {
5944
4517
  }
5945
4518
  function serializeObjectId(buffer, key, value, index, isArray) {
5946
4519
  // Write the type
5947
- buffer[index++] = constants.BSON_DATA_OID;
4520
+ buffer[index++] = BSON_DATA_OID;
5948
4521
  // Number of written bytes
5949
4522
  var numberOfWrittenBytes = !isArray
5950
4523
  ? buffer.write(key, index, undefined, 'utf8')
@@ -5956,8 +4529,10 @@ function serializeObjectId(buffer, key, value, index, isArray) {
5956
4529
  if (typeof value.id === 'string') {
5957
4530
  buffer.write(value.id, index, undefined, 'binary');
5958
4531
  }
5959
- else if (value.id && value.id.copy) {
5960
- value.id.copy(buffer, index, 0, 12);
4532
+ else if (isUint8Array(value.id)) {
4533
+ // Use the standard JS methods here because buffer.copy() is buggy with the
4534
+ // browser polyfill
4535
+ buffer.set(value.id.subarray(0, 12), index);
5961
4536
  }
5962
4537
  else {
5963
4538
  throw new TypeError('object [' + JSON.stringify(value) + '] is not a valid ObjectId');
@@ -5967,7 +4542,7 @@ function serializeObjectId(buffer, key, value, index, isArray) {
5967
4542
  }
5968
4543
  function serializeBuffer(buffer, key, value, index, isArray) {
5969
4544
  // Write the type
5970
- buffer[index++] = constants.BSON_DATA_BINARY;
4545
+ buffer[index++] = BSON_DATA_BINARY;
5971
4546
  // Number of written bytes
5972
4547
  var numberOfWrittenBytes = !isArray
5973
4548
  ? buffer.write(key, index, undefined, 'utf8')
@@ -5983,9 +4558,9 @@ function serializeBuffer(buffer, key, value, index, isArray) {
5983
4558
  buffer[index++] = (size >> 16) & 0xff;
5984
4559
  buffer[index++] = (size >> 24) & 0xff;
5985
4560
  // Write the default subtype
5986
- buffer[index++] = constants.BSON_BINARY_SUBTYPE_DEFAULT;
4561
+ buffer[index++] = BSON_BINARY_SUBTYPE_DEFAULT;
5987
4562
  // Copy the content form the binary field to the buffer
5988
- buffer.set(ensure_buffer.ensureBuffer(value), index);
4563
+ buffer.set(ensureBuffer(value), index);
5989
4564
  // Adjust the index
5990
4565
  index = index + size;
5991
4566
  return index;
@@ -6004,7 +4579,7 @@ function serializeObject(buffer, key, value, index, checkKeys, depth, serializeF
6004
4579
  // Push value to stack
6005
4580
  path.push(value);
6006
4581
  // Write the type
6007
- buffer[index++] = Array.isArray(value) ? constants.BSON_DATA_ARRAY : constants.BSON_DATA_OBJECT;
4582
+ buffer[index++] = Array.isArray(value) ? BSON_DATA_ARRAY : BSON_DATA_OBJECT;
6008
4583
  // Number of written bytes
6009
4584
  var numberOfWrittenBytes = !isArray
6010
4585
  ? buffer.write(key, index, undefined, 'utf8')
@@ -6018,7 +4593,7 @@ function serializeObject(buffer, key, value, index, checkKeys, depth, serializeF
6018
4593
  return endIndex;
6019
4594
  }
6020
4595
  function serializeDecimal128(buffer, key, value, index, isArray) {
6021
- buffer[index++] = constants.BSON_DATA_DECIMAL128;
4596
+ buffer[index++] = BSON_DATA_DECIMAL128;
6022
4597
  // Number of written bytes
6023
4598
  var numberOfWrittenBytes = !isArray
6024
4599
  ? buffer.write(key, index, undefined, 'utf8')
@@ -6027,13 +4602,15 @@ function serializeDecimal128(buffer, key, value, index, isArray) {
6027
4602
  index = index + numberOfWrittenBytes;
6028
4603
  buffer[index++] = 0;
6029
4604
  // Write the data from the value
6030
- value.bytes.copy(buffer, index, 0, 16);
4605
+ // Prefer the standard JS methods because their typechecking is not buggy,
4606
+ // unlike the `buffer` polyfill's.
4607
+ buffer.set(value.bytes.subarray(0, 16), index);
6031
4608
  return index + 16;
6032
4609
  }
6033
4610
  function serializeLong(buffer, key, value, index, isArray) {
6034
4611
  // Write the type
6035
4612
  buffer[index++] =
6036
- value._bsontype === 'Long' ? constants.BSON_DATA_LONG : constants.BSON_DATA_TIMESTAMP;
4613
+ value._bsontype === 'Long' ? BSON_DATA_LONG : BSON_DATA_TIMESTAMP;
6037
4614
  // Number of written bytes
6038
4615
  var numberOfWrittenBytes = !isArray
6039
4616
  ? buffer.write(key, index, undefined, 'utf8')
@@ -6059,7 +4636,7 @@ function serializeLong(buffer, key, value, index, isArray) {
6059
4636
  function serializeInt32(buffer, key, value, index, isArray) {
6060
4637
  value = value.valueOf();
6061
4638
  // Set int type 32 bits or less
6062
- buffer[index++] = constants.BSON_DATA_INT;
4639
+ buffer[index++] = BSON_DATA_INT;
6063
4640
  // Number of written bytes
6064
4641
  var numberOfWrittenBytes = !isArray
6065
4642
  ? buffer.write(key, index, undefined, 'utf8')
@@ -6076,7 +4653,7 @@ function serializeInt32(buffer, key, value, index, isArray) {
6076
4653
  }
6077
4654
  function serializeDouble(buffer, key, value, index, isArray) {
6078
4655
  // Encode as double
6079
- buffer[index++] = constants.BSON_DATA_NUMBER;
4656
+ buffer[index++] = BSON_DATA_NUMBER;
6080
4657
  // Number of written bytes
6081
4658
  var numberOfWrittenBytes = !isArray
6082
4659
  ? buffer.write(key, index, undefined, 'utf8')
@@ -6085,13 +4662,13 @@ function serializeDouble(buffer, key, value, index, isArray) {
6085
4662
  index = index + numberOfWrittenBytes;
6086
4663
  buffer[index++] = 0;
6087
4664
  // Write float
6088
- float_parser.writeIEEE754(buffer, value.value, index, 'little', 52, 8);
4665
+ writeIEEE754(buffer, value.value, index, 'little', 52, 8);
6089
4666
  // Adjust index
6090
4667
  index = index + 8;
6091
4668
  return index;
6092
4669
  }
6093
4670
  function serializeFunction(buffer, key, value, index, _checkKeys, _depth, isArray) {
6094
- buffer[index++] = constants.BSON_DATA_CODE;
4671
+ buffer[index++] = BSON_DATA_CODE;
6095
4672
  // Number of written bytes
6096
4673
  var numberOfWrittenBytes = !isArray
6097
4674
  ? buffer.write(key, index, undefined, 'utf8')
@@ -6100,7 +4677,7 @@ function serializeFunction(buffer, key, value, index, _checkKeys, _depth, isArra
6100
4677
  index = index + numberOfWrittenBytes;
6101
4678
  buffer[index++] = 0;
6102
4679
  // Function string
6103
- var functionString = utils.normalizedFunctionString(value);
4680
+ var functionString = normalizedFunctionString(value);
6104
4681
  // Write the string
6105
4682
  var size = buffer.write(functionString, index + 4, undefined, 'utf8') + 1;
6106
4683
  // Write the size of the string to buffer
@@ -6122,7 +4699,7 @@ function serializeCode(buffer, key, value, index, checkKeys, depth, serializeFun
6122
4699
  if (isArray === void 0) { isArray = false; }
6123
4700
  if (value.scope && typeof value.scope === 'object') {
6124
4701
  // Write the type
6125
- buffer[index++] = constants.BSON_DATA_CODE_W_SCOPE;
4702
+ buffer[index++] = BSON_DATA_CODE_W_SCOPE;
6126
4703
  // Number of written bytes
6127
4704
  var numberOfWrittenBytes = !isArray
6128
4705
  ? buffer.write(key, index, undefined, 'utf8')
@@ -6163,7 +4740,7 @@ function serializeCode(buffer, key, value, index, checkKeys, depth, serializeFun
6163
4740
  buffer[index++] = 0;
6164
4741
  }
6165
4742
  else {
6166
- buffer[index++] = constants.BSON_DATA_CODE;
4743
+ buffer[index++] = BSON_DATA_CODE;
6167
4744
  // Number of written bytes
6168
4745
  var numberOfWrittenBytes = !isArray
6169
4746
  ? buffer.write(key, index, undefined, 'utf8')
@@ -6189,7 +4766,7 @@ function serializeCode(buffer, key, value, index, checkKeys, depth, serializeFun
6189
4766
  }
6190
4767
  function serializeBinary(buffer, key, value, index, isArray) {
6191
4768
  // Write the type
6192
- buffer[index++] = constants.BSON_DATA_BINARY;
4769
+ buffer[index++] = BSON_DATA_BINARY;
6193
4770
  // Number of written bytes
6194
4771
  var numberOfWrittenBytes = !isArray
6195
4772
  ? buffer.write(key, index, undefined, 'utf8')
@@ -6202,7 +4779,7 @@ function serializeBinary(buffer, key, value, index, isArray) {
6202
4779
  // Calculate size
6203
4780
  var size = value.position;
6204
4781
  // Add the deprecated 02 type 4 bytes of size to total
6205
- if (value.sub_type === binary.Binary.SUBTYPE_BYTE_ARRAY)
4782
+ if (value.sub_type === Binary.SUBTYPE_BYTE_ARRAY)
6206
4783
  size = size + 4;
6207
4784
  // Write the size of the string to buffer
6208
4785
  buffer[index++] = size & 0xff;
@@ -6212,7 +4789,7 @@ function serializeBinary(buffer, key, value, index, isArray) {
6212
4789
  // Write the subtype to the buffer
6213
4790
  buffer[index++] = value.sub_type;
6214
4791
  // If we have binary type 2 the 4 first bytes are the size
6215
- if (value.sub_type === binary.Binary.SUBTYPE_BYTE_ARRAY) {
4792
+ if (value.sub_type === Binary.SUBTYPE_BYTE_ARRAY) {
6216
4793
  size = size - 4;
6217
4794
  buffer[index++] = size & 0xff;
6218
4795
  buffer[index++] = (size >> 8) & 0xff;
@@ -6227,7 +4804,7 @@ function serializeBinary(buffer, key, value, index, isArray) {
6227
4804
  }
6228
4805
  function serializeSymbol(buffer, key, value, index, isArray) {
6229
4806
  // Write the type
6230
- buffer[index++] = constants.BSON_DATA_SYMBOL;
4807
+ buffer[index++] = BSON_DATA_SYMBOL;
6231
4808
  // Number of written bytes
6232
4809
  var numberOfWrittenBytes = !isArray
6233
4810
  ? buffer.write(key, index, undefined, 'utf8')
@@ -6250,7 +4827,7 @@ function serializeSymbol(buffer, key, value, index, isArray) {
6250
4827
  }
6251
4828
  function serializeDBRef(buffer, key, value, index, depth, serializeFunctions, isArray) {
6252
4829
  // Write the type
6253
- buffer[index++] = constants.BSON_DATA_OBJECT;
4830
+ buffer[index++] = BSON_DATA_OBJECT;
6254
4831
  // Number of written bytes
6255
4832
  var numberOfWrittenBytes = !isArray
6256
4833
  ? buffer.write(key, index, undefined, 'utf8')
@@ -6315,7 +4892,7 @@ function serializeInto(buffer, object, checkKeys, startingIndex, depth, serializ
6315
4892
  else if (typeof value === 'boolean') {
6316
4893
  index = serializeBoolean(buffer, key, value, index, true);
6317
4894
  }
6318
- else if (value instanceof Date || utils.isDate(value)) {
4895
+ else if (value instanceof Date || isDate(value)) {
6319
4896
  index = serializeDate(buffer, key, value, index, true);
6320
4897
  }
6321
4898
  else if (value === undefined) {
@@ -6327,17 +4904,17 @@ function serializeInto(buffer, object, checkKeys, startingIndex, depth, serializ
6327
4904
  else if (value['_bsontype'] === 'ObjectId' || value['_bsontype'] === 'ObjectID') {
6328
4905
  index = serializeObjectId(buffer, key, value, index, true);
6329
4906
  }
6330
- else if (utils.isUint8Array(value)) {
4907
+ else if (isUint8Array(value)) {
6331
4908
  index = serializeBuffer(buffer, key, value, index, true);
6332
4909
  }
6333
- else if (value instanceof RegExp || utils.isRegExp(value)) {
4910
+ else if (value instanceof RegExp || isRegExp(value)) {
6334
4911
  index = serializeRegExp(buffer, key, value, index, true);
6335
4912
  }
6336
4913
  else if (typeof value === 'object' && value['_bsontype'] == null) {
6337
4914
  index = serializeObject(buffer, key, value, index, checkKeys, depth, serializeFunctions, ignoreUndefined, true, path);
6338
4915
  }
6339
4916
  else if (typeof value === 'object' &&
6340
- extended_json.isBSONType(value) &&
4917
+ isBSONType(value) &&
6341
4918
  value._bsontype === 'Decimal128') {
6342
4919
  index = serializeDecimal128(buffer, key, value, index, true);
6343
4920
  }
@@ -6376,7 +4953,7 @@ function serializeInto(buffer, object, checkKeys, startingIndex, depth, serializ
6376
4953
  }
6377
4954
  }
6378
4955
  }
6379
- else if (object instanceof map.Map || utils.isMap(object)) {
4956
+ else if (object instanceof bsonMap || isMap(object)) {
6380
4957
  var iterator = object.entries();
6381
4958
  var done = false;
6382
4959
  while (!done) {
@@ -6413,13 +4990,13 @@ function serializeInto(buffer, object, checkKeys, startingIndex, depth, serializ
6413
4990
  else if (type === 'number') {
6414
4991
  index = serializeNumber(buffer, key, value, index);
6415
4992
  }
6416
- else if (type === 'bigint' || utils.isBigInt64Array(value) || utils.isBigUInt64Array(value)) {
4993
+ else if (type === 'bigint' || isBigInt64Array(value) || isBigUInt64Array(value)) {
6417
4994
  throw new TypeError('Unsupported type BigInt, please use Decimal128');
6418
4995
  }
6419
4996
  else if (type === 'boolean') {
6420
4997
  index = serializeBoolean(buffer, key, value, index);
6421
4998
  }
6422
- else if (value instanceof Date || utils.isDate(value)) {
4999
+ else if (value instanceof Date || isDate(value)) {
6423
5000
  index = serializeDate(buffer, key, value, index);
6424
5001
  }
6425
5002
  else if (value === null || (value === undefined && ignoreUndefined === false)) {
@@ -6428,10 +5005,10 @@ function serializeInto(buffer, object, checkKeys, startingIndex, depth, serializ
6428
5005
  else if (value['_bsontype'] === 'ObjectId' || value['_bsontype'] === 'ObjectID') {
6429
5006
  index = serializeObjectId(buffer, key, value, index);
6430
5007
  }
6431
- else if (utils.isUint8Array(value)) {
5008
+ else if (isUint8Array(value)) {
6432
5009
  index = serializeBuffer(buffer, key, value, index);
6433
5010
  }
6434
- else if (value instanceof RegExp || utils.isRegExp(value)) {
5011
+ else if (value instanceof RegExp || isRegExp(value)) {
6435
5012
  index = serializeRegExp(buffer, key, value, index);
6436
5013
  }
6437
5014
  else if (type === 'object' && value['_bsontype'] == null) {
@@ -6523,7 +5100,7 @@ function serializeInto(buffer, object, checkKeys, startingIndex, depth, serializ
6523
5100
  else if (type === 'boolean') {
6524
5101
  index = serializeBoolean(buffer, key, value, index);
6525
5102
  }
6526
- else if (value instanceof Date || utils.isDate(value)) {
5103
+ else if (value instanceof Date || isDate(value)) {
6527
5104
  index = serializeDate(buffer, key, value, index);
6528
5105
  }
6529
5106
  else if (value === undefined) {
@@ -6536,10 +5113,10 @@ function serializeInto(buffer, object, checkKeys, startingIndex, depth, serializ
6536
5113
  else if (value['_bsontype'] === 'ObjectId' || value['_bsontype'] === 'ObjectID') {
6537
5114
  index = serializeObjectId(buffer, key, value, index);
6538
5115
  }
6539
- else if (utils.isUint8Array(value)) {
5116
+ else if (isUint8Array(value)) {
6540
5117
  index = serializeBuffer(buffer, key, value, index);
6541
5118
  }
6542
- else if (value instanceof RegExp || utils.isRegExp(value)) {
5119
+ else if (value instanceof RegExp || isRegExp(value)) {
6543
5120
  index = serializeRegExp(buffer, key, value, index);
6544
5121
  }
6545
5122
  else if (type === 'object' && value['_bsontype'] == null) {
@@ -6596,97 +5173,12 @@ function serializeInto(buffer, object, checkKeys, startingIndex, depth, serializ
6596
5173
  buffer[startingIndex++] = (size >> 24) & 0xff;
6597
5174
  return index;
6598
5175
  }
6599
- exports.serializeInto = serializeInto;
6600
- //# sourceMappingURL=serializer.js.map
6601
- });
6602
-
6603
- unwrapExports(serializer);
6604
- serializer.serializeInto;
6605
-
6606
- var bson = createCommonjsModule(function (module, exports) {
6607
- Object.defineProperty(exports, "__esModule", { value: true });
6608
- 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;
6609
- exports.deserializeStream = exports.calculateObjectSize = exports.deserialize = exports.serializeWithBufferAndIndex = exports.serialize = exports.setInternalBufferSize = void 0;
6610
-
6611
-
6612
- Object.defineProperty(exports, "Binary", { enumerable: true, get: function () { return binary.Binary; } });
6613
-
6614
- Object.defineProperty(exports, "Code", { enumerable: true, get: function () { return code.Code; } });
6615
-
6616
- Object.defineProperty(exports, "DBRef", { enumerable: true, get: function () { return db_ref.DBRef; } });
6617
-
6618
- Object.defineProperty(exports, "Decimal128", { enumerable: true, get: function () { return decimal128.Decimal128; } });
6619
-
6620
- Object.defineProperty(exports, "Double", { enumerable: true, get: function () { return double_1.Double; } });
6621
-
6622
5176
 
6623
-
6624
- Object.defineProperty(exports, "Int32", { enumerable: true, get: function () { return int_32.Int32; } });
6625
-
6626
- Object.defineProperty(exports, "Long", { enumerable: true, get: function () { return long_1.Long; } });
6627
-
6628
- Object.defineProperty(exports, "Map", { enumerable: true, get: function () { return map.Map; } });
6629
-
6630
- Object.defineProperty(exports, "MaxKey", { enumerable: true, get: function () { return max_key.MaxKey; } });
6631
-
6632
- Object.defineProperty(exports, "MinKey", { enumerable: true, get: function () { return min_key.MinKey; } });
6633
-
6634
- Object.defineProperty(exports, "ObjectId", { enumerable: true, get: function () { return objectid.ObjectId; } });
6635
- Object.defineProperty(exports, "ObjectID", { enumerable: true, get: function () { return objectid.ObjectId; } });
6636
-
6637
- // Parts of the parser
6638
-
6639
-
6640
-
6641
- Object.defineProperty(exports, "BSONRegExp", { enumerable: true, get: function () { return regexp.BSONRegExp; } });
6642
-
6643
- Object.defineProperty(exports, "BSONSymbol", { enumerable: true, get: function () { return symbol.BSONSymbol; } });
6644
-
6645
- Object.defineProperty(exports, "Timestamp", { enumerable: true, get: function () { return timestamp.Timestamp; } });
6646
-
6647
- Object.defineProperty(exports, "UUID", { enumerable: true, get: function () { return uuid.UUID; } });
6648
-
6649
- Object.defineProperty(exports, "BSON_BINARY_SUBTYPE_BYTE_ARRAY", { enumerable: true, get: function () { return constants.BSON_BINARY_SUBTYPE_BYTE_ARRAY; } });
6650
- Object.defineProperty(exports, "BSON_BINARY_SUBTYPE_DEFAULT", { enumerable: true, get: function () { return constants.BSON_BINARY_SUBTYPE_DEFAULT; } });
6651
- Object.defineProperty(exports, "BSON_BINARY_SUBTYPE_FUNCTION", { enumerable: true, get: function () { return constants.BSON_BINARY_SUBTYPE_FUNCTION; } });
6652
- Object.defineProperty(exports, "BSON_BINARY_SUBTYPE_MD5", { enumerable: true, get: function () { return constants.BSON_BINARY_SUBTYPE_MD5; } });
6653
- Object.defineProperty(exports, "BSON_BINARY_SUBTYPE_USER_DEFINED", { enumerable: true, get: function () { return constants.BSON_BINARY_SUBTYPE_USER_DEFINED; } });
6654
- Object.defineProperty(exports, "BSON_BINARY_SUBTYPE_UUID", { enumerable: true, get: function () { return constants.BSON_BINARY_SUBTYPE_UUID; } });
6655
- Object.defineProperty(exports, "BSON_BINARY_SUBTYPE_UUID_NEW", { enumerable: true, get: function () { return constants.BSON_BINARY_SUBTYPE_UUID_NEW; } });
6656
- Object.defineProperty(exports, "BSON_DATA_ARRAY", { enumerable: true, get: function () { return constants.BSON_DATA_ARRAY; } });
6657
- Object.defineProperty(exports, "BSON_DATA_BINARY", { enumerable: true, get: function () { return constants.BSON_DATA_BINARY; } });
6658
- Object.defineProperty(exports, "BSON_DATA_BOOLEAN", { enumerable: true, get: function () { return constants.BSON_DATA_BOOLEAN; } });
6659
- Object.defineProperty(exports, "BSON_DATA_CODE", { enumerable: true, get: function () { return constants.BSON_DATA_CODE; } });
6660
- Object.defineProperty(exports, "BSON_DATA_CODE_W_SCOPE", { enumerable: true, get: function () { return constants.BSON_DATA_CODE_W_SCOPE; } });
6661
- Object.defineProperty(exports, "BSON_DATA_DATE", { enumerable: true, get: function () { return constants.BSON_DATA_DATE; } });
6662
- Object.defineProperty(exports, "BSON_DATA_DBPOINTER", { enumerable: true, get: function () { return constants.BSON_DATA_DBPOINTER; } });
6663
- Object.defineProperty(exports, "BSON_DATA_DECIMAL128", { enumerable: true, get: function () { return constants.BSON_DATA_DECIMAL128; } });
6664
- Object.defineProperty(exports, "BSON_DATA_INT", { enumerable: true, get: function () { return constants.BSON_DATA_INT; } });
6665
- Object.defineProperty(exports, "BSON_DATA_LONG", { enumerable: true, get: function () { return constants.BSON_DATA_LONG; } });
6666
- Object.defineProperty(exports, "BSON_DATA_MAX_KEY", { enumerable: true, get: function () { return constants.BSON_DATA_MAX_KEY; } });
6667
- Object.defineProperty(exports, "BSON_DATA_MIN_KEY", { enumerable: true, get: function () { return constants.BSON_DATA_MIN_KEY; } });
6668
- Object.defineProperty(exports, "BSON_DATA_NULL", { enumerable: true, get: function () { return constants.BSON_DATA_NULL; } });
6669
- Object.defineProperty(exports, "BSON_DATA_NUMBER", { enumerable: true, get: function () { return constants.BSON_DATA_NUMBER; } });
6670
- Object.defineProperty(exports, "BSON_DATA_OBJECT", { enumerable: true, get: function () { return constants.BSON_DATA_OBJECT; } });
6671
- Object.defineProperty(exports, "BSON_DATA_OID", { enumerable: true, get: function () { return constants.BSON_DATA_OID; } });
6672
- Object.defineProperty(exports, "BSON_DATA_REGEXP", { enumerable: true, get: function () { return constants.BSON_DATA_REGEXP; } });
6673
- Object.defineProperty(exports, "BSON_DATA_STRING", { enumerable: true, get: function () { return constants.BSON_DATA_STRING; } });
6674
- Object.defineProperty(exports, "BSON_DATA_SYMBOL", { enumerable: true, get: function () { return constants.BSON_DATA_SYMBOL; } });
6675
- Object.defineProperty(exports, "BSON_DATA_TIMESTAMP", { enumerable: true, get: function () { return constants.BSON_DATA_TIMESTAMP; } });
6676
- Object.defineProperty(exports, "BSON_DATA_UNDEFINED", { enumerable: true, get: function () { return constants.BSON_DATA_UNDEFINED; } });
6677
- Object.defineProperty(exports, "BSON_INT32_MAX", { enumerable: true, get: function () { return constants.BSON_INT32_MAX; } });
6678
- Object.defineProperty(exports, "BSON_INT32_MIN", { enumerable: true, get: function () { return constants.BSON_INT32_MIN; } });
6679
- Object.defineProperty(exports, "BSON_INT64_MAX", { enumerable: true, get: function () { return constants.BSON_INT64_MAX; } });
6680
- Object.defineProperty(exports, "BSON_INT64_MIN", { enumerable: true, get: function () { return constants.BSON_INT64_MIN; } });
6681
- var extended_json_2 = extended_json;
6682
- Object.defineProperty(exports, "EJSON", { enumerable: true, get: function () { return extended_json_2.EJSON; } });
6683
- var timestamp_2 = timestamp;
6684
- Object.defineProperty(exports, "LongWithoutOverridesClass", { enumerable: true, get: function () { return timestamp_2.LongWithoutOverridesClass; } });
6685
5177
  /** @internal */
6686
5178
  // Default Max Size
6687
5179
  var MAXSIZE = 1024 * 1024 * 17;
6688
5180
  // Current Internal Temporary Serialization Buffer
6689
- var buffer$1 = buffer.Buffer.alloc(MAXSIZE);
5181
+ var buffer = Buffer.alloc(MAXSIZE);
6690
5182
  /**
6691
5183
  * Sets the size of the internal serialization buffer.
6692
5184
  *
@@ -6695,11 +5187,10 @@ var buffer$1 = buffer.Buffer.alloc(MAXSIZE);
6695
5187
  */
6696
5188
  function setInternalBufferSize(size) {
6697
5189
  // Resize the internal serialization buffer if needed
6698
- if (buffer$1.length < size) {
6699
- buffer$1 = buffer.Buffer.alloc(size);
5190
+ if (buffer.length < size) {
5191
+ buffer = Buffer.alloc(size);
6700
5192
  }
6701
5193
  }
6702
- exports.setInternalBufferSize = setInternalBufferSize;
6703
5194
  /**
6704
5195
  * Serialize a Javascript object.
6705
5196
  *
@@ -6715,19 +5206,18 @@ function serialize(object, options) {
6715
5206
  var ignoreUndefined = typeof options.ignoreUndefined === 'boolean' ? options.ignoreUndefined : true;
6716
5207
  var minInternalBufferSize = typeof options.minInternalBufferSize === 'number' ? options.minInternalBufferSize : MAXSIZE;
6717
5208
  // Resize the internal serialization buffer if needed
6718
- if (buffer$1.length < minInternalBufferSize) {
6719
- buffer$1 = buffer.Buffer.alloc(minInternalBufferSize);
5209
+ if (buffer.length < minInternalBufferSize) {
5210
+ buffer = Buffer.alloc(minInternalBufferSize);
6720
5211
  }
6721
5212
  // Attempt to serialize
6722
- var serializationIndex = serializer.serializeInto(buffer$1, object, checkKeys, 0, 0, serializeFunctions, ignoreUndefined, []);
5213
+ var serializationIndex = serializeInto(buffer, object, checkKeys, 0, 0, serializeFunctions, ignoreUndefined, []);
6723
5214
  // Create the final buffer
6724
- var finishedBuffer = buffer.Buffer.alloc(serializationIndex);
5215
+ var finishedBuffer = Buffer.alloc(serializationIndex);
6725
5216
  // Copy into the finished buffer
6726
- buffer$1.copy(finishedBuffer, 0, 0, finishedBuffer.length);
5217
+ buffer.copy(finishedBuffer, 0, 0, finishedBuffer.length);
6727
5218
  // Return the buffer
6728
5219
  return finishedBuffer;
6729
5220
  }
6730
- exports.serialize = serialize;
6731
5221
  /**
6732
5222
  * Serialize a Javascript object using a predefined Buffer and index into the buffer,
6733
5223
  * useful when pre-allocating the space for serialization.
@@ -6745,12 +5235,11 @@ function serializeWithBufferAndIndex(object, finalBuffer, options) {
6745
5235
  var ignoreUndefined = typeof options.ignoreUndefined === 'boolean' ? options.ignoreUndefined : true;
6746
5236
  var startIndex = typeof options.index === 'number' ? options.index : 0;
6747
5237
  // Attempt to serialize
6748
- var serializationIndex = serializer.serializeInto(buffer$1, object, checkKeys, 0, 0, serializeFunctions, ignoreUndefined);
6749
- buffer$1.copy(finalBuffer, startIndex, 0, serializationIndex);
5238
+ var serializationIndex = serializeInto(buffer, object, checkKeys, 0, 0, serializeFunctions, ignoreUndefined);
5239
+ buffer.copy(finalBuffer, startIndex, 0, serializationIndex);
6750
5240
  // Return the index
6751
5241
  return startIndex + serializationIndex - 1;
6752
5242
  }
6753
- exports.serializeWithBufferAndIndex = serializeWithBufferAndIndex;
6754
5243
  /**
6755
5244
  * Deserialize data as BSON.
6756
5245
  *
@@ -6760,9 +5249,8 @@ exports.serializeWithBufferAndIndex = serializeWithBufferAndIndex;
6760
5249
  */
6761
5250
  function deserialize(buffer, options) {
6762
5251
  if (options === void 0) { options = {}; }
6763
- return deserializer.deserialize(ensure_buffer.ensureBuffer(buffer), options);
5252
+ return deserialize$1(buffer instanceof Buffer ? buffer : ensureBuffer(buffer), options);
6764
5253
  }
6765
- exports.deserialize = deserialize;
6766
5254
  /**
6767
5255
  * Calculate the bson size for a passed in Javascript object.
6768
5256
  *
@@ -6775,9 +5263,8 @@ function calculateObjectSize(object, options) {
6775
5263
  options = options || {};
6776
5264
  var serializeFunctions = typeof options.serializeFunctions === 'boolean' ? options.serializeFunctions : false;
6777
5265
  var ignoreUndefined = typeof options.ignoreUndefined === 'boolean' ? options.ignoreUndefined : true;
6778
- return calculate_size.calculateObjectSize(object, serializeFunctions, ignoreUndefined);
5266
+ return calculateObjectSize$1(object, serializeFunctions, ignoreUndefined);
6779
5267
  }
6780
- exports.calculateObjectSize = calculateObjectSize;
6781
5268
  /**
6782
5269
  * Deserialize stream data as BSON documents.
6783
5270
  *
@@ -6792,7 +5279,7 @@ exports.calculateObjectSize = calculateObjectSize;
6792
5279
  */
6793
5280
  function deserializeStream(data, startIndex, numberOfDocuments, documents, docStartIndex, options) {
6794
5281
  var internalOptions = Object.assign({ allowObjectSmallerThanBufferSize: true, index: 0 }, options);
6795
- var bufferData = ensure_buffer.ensureBuffer(data);
5282
+ var bufferData = ensureBuffer(data);
6796
5283
  var index = startIndex;
6797
5284
  // Loop over all documents
6798
5285
  for (var i = 0; i < numberOfDocuments; i++) {
@@ -6804,14 +5291,13 @@ function deserializeStream(data, startIndex, numberOfDocuments, documents, docSt
6804
5291
  // Update options with index
6805
5292
  internalOptions.index = index;
6806
5293
  // Parse the document at this point
6807
- documents[docStartIndex + i] = deserializer.deserialize(bufferData, internalOptions);
5294
+ documents[docStartIndex + i] = deserialize$1(bufferData, internalOptions);
6808
5295
  // Adjust index by the document size
6809
5296
  index = index + size;
6810
5297
  }
6811
5298
  // Return object containing end index of parsing and list of documents
6812
5299
  return index;
6813
5300
  }
6814
- exports.deserializeStream = deserializeStream;
6815
5301
  /**
6816
5302
  * BSON default export
6817
5303
  * @deprecated Please use named exports
@@ -6821,23 +5307,23 @@ exports.deserializeStream = deserializeStream;
6821
5307
  * @public
6822
5308
  */
6823
5309
  var BSON = {
6824
- Binary: binary.Binary,
6825
- Code: code.Code,
6826
- DBRef: db_ref.DBRef,
6827
- Decimal128: decimal128.Decimal128,
6828
- Double: double_1.Double,
6829
- Int32: int_32.Int32,
6830
- Long: long_1.Long,
6831
- UUID: uuid.UUID,
6832
- Map: map.Map,
6833
- MaxKey: max_key.MaxKey,
6834
- MinKey: min_key.MinKey,
6835
- ObjectId: objectid.ObjectId,
6836
- ObjectID: objectid.ObjectId,
6837
- BSONRegExp: regexp.BSONRegExp,
6838
- BSONSymbol: symbol.BSONSymbol,
6839
- Timestamp: timestamp.Timestamp,
6840
- EJSON: extended_json.EJSON,
5310
+ Binary: Binary,
5311
+ Code: Code,
5312
+ DBRef: DBRef,
5313
+ Decimal128: Decimal128,
5314
+ Double: Double,
5315
+ Int32: Int32,
5316
+ Long: Long,
5317
+ UUID: UUID,
5318
+ Map: bsonMap,
5319
+ MaxKey: MaxKey,
5320
+ MinKey: MinKey,
5321
+ ObjectId: ObjectId,
5322
+ ObjectID: ObjectId,
5323
+ BSONRegExp: BSONRegExp,
5324
+ BSONSymbol: BSONSymbol,
5325
+ Timestamp: Timestamp,
5326
+ EJSON: EJSON,
6841
5327
  setInternalBufferSize: setInternalBufferSize,
6842
5328
  serialize: serialize,
6843
5329
  serializeWithBufferAndIndex: serializeWithBufferAndIndex,
@@ -6845,68 +5331,7 @@ var BSON = {
6845
5331
  calculateObjectSize: calculateObjectSize,
6846
5332
  deserializeStream: deserializeStream
6847
5333
  };
6848
- exports.default = BSON;
6849
- //# sourceMappingURL=bson.js.map
6850
- });
6851
-
6852
- var bson$1 = unwrapExports(bson);
6853
- var bson_1 = bson.ObjectID;
6854
- var bson_2 = bson.Decimal128;
6855
- var bson_3 = bson.BSONRegExp;
6856
- var bson_4 = bson.MaxKey;
6857
- var bson_5 = bson.MinKey;
6858
- var bson_6 = bson.Int32;
6859
- var bson_7 = bson.Double;
6860
- var bson_8 = bson.Timestamp;
6861
- var bson_9 = bson.Long;
6862
- var bson_10 = bson.UUID;
6863
- var bson_11 = bson.ObjectId;
6864
- var bson_12 = bson.Binary;
6865
- var bson_13 = bson.DBRef;
6866
- var bson_14 = bson.BSONSymbol;
6867
- var bson_15 = bson.Map;
6868
- var bson_16 = bson.Code;
6869
- var bson_17 = bson.LongWithoutOverridesClass;
6870
- var bson_18 = bson.EJSON;
6871
- var bson_19 = bson.BSON_INT64_MIN;
6872
- var bson_20 = bson.BSON_INT64_MAX;
6873
- var bson_21 = bson.BSON_INT32_MIN;
6874
- var bson_22 = bson.BSON_INT32_MAX;
6875
- var bson_23 = bson.BSON_DATA_UNDEFINED;
6876
- var bson_24 = bson.BSON_DATA_TIMESTAMP;
6877
- var bson_25 = bson.BSON_DATA_SYMBOL;
6878
- var bson_26 = bson.BSON_DATA_STRING;
6879
- var bson_27 = bson.BSON_DATA_REGEXP;
6880
- var bson_28 = bson.BSON_DATA_OID;
6881
- var bson_29 = bson.BSON_DATA_OBJECT;
6882
- var bson_30 = bson.BSON_DATA_NUMBER;
6883
- var bson_31 = bson.BSON_DATA_NULL;
6884
- var bson_32 = bson.BSON_DATA_MIN_KEY;
6885
- var bson_33 = bson.BSON_DATA_MAX_KEY;
6886
- var bson_34 = bson.BSON_DATA_LONG;
6887
- var bson_35 = bson.BSON_DATA_INT;
6888
- var bson_36 = bson.BSON_DATA_DECIMAL128;
6889
- var bson_37 = bson.BSON_DATA_DBPOINTER;
6890
- var bson_38 = bson.BSON_DATA_DATE;
6891
- var bson_39 = bson.BSON_DATA_CODE_W_SCOPE;
6892
- var bson_40 = bson.BSON_DATA_CODE;
6893
- var bson_41 = bson.BSON_DATA_BOOLEAN;
6894
- var bson_42 = bson.BSON_DATA_BINARY;
6895
- var bson_43 = bson.BSON_DATA_ARRAY;
6896
- var bson_44 = bson.BSON_BINARY_SUBTYPE_UUID_NEW;
6897
- var bson_45 = bson.BSON_BINARY_SUBTYPE_UUID;
6898
- var bson_46 = bson.BSON_BINARY_SUBTYPE_USER_DEFINED;
6899
- var bson_47 = bson.BSON_BINARY_SUBTYPE_MD5;
6900
- var bson_48 = bson.BSON_BINARY_SUBTYPE_FUNCTION;
6901
- var bson_49 = bson.BSON_BINARY_SUBTYPE_DEFAULT;
6902
- var bson_50 = bson.BSON_BINARY_SUBTYPE_BYTE_ARRAY;
6903
- var bson_51 = bson.deserializeStream;
6904
- var bson_52 = bson.calculateObjectSize;
6905
- var bson_53 = bson.deserialize;
6906
- var bson_54 = bson.serializeWithBufferAndIndex;
6907
- var bson_55 = bson.serialize;
6908
- var bson_56 = bson.setInternalBufferSize;
6909
5334
 
6910
- export default bson$1;
6911
- export { bson_3 as BSONRegExp, bson_14 as BSONSymbol, bson_50 as BSON_BINARY_SUBTYPE_BYTE_ARRAY, bson_49 as BSON_BINARY_SUBTYPE_DEFAULT, bson_48 as BSON_BINARY_SUBTYPE_FUNCTION, bson_47 as BSON_BINARY_SUBTYPE_MD5, bson_46 as BSON_BINARY_SUBTYPE_USER_DEFINED, bson_45 as BSON_BINARY_SUBTYPE_UUID, bson_44 as BSON_BINARY_SUBTYPE_UUID_NEW, bson_43 as BSON_DATA_ARRAY, bson_42 as BSON_DATA_BINARY, bson_41 as BSON_DATA_BOOLEAN, bson_40 as BSON_DATA_CODE, bson_39 as BSON_DATA_CODE_W_SCOPE, bson_38 as BSON_DATA_DATE, bson_37 as BSON_DATA_DBPOINTER, bson_36 as BSON_DATA_DECIMAL128, bson_35 as BSON_DATA_INT, bson_34 as BSON_DATA_LONG, bson_33 as BSON_DATA_MAX_KEY, bson_32 as BSON_DATA_MIN_KEY, bson_31 as BSON_DATA_NULL, bson_30 as BSON_DATA_NUMBER, bson_29 as BSON_DATA_OBJECT, bson_28 as BSON_DATA_OID, bson_27 as BSON_DATA_REGEXP, bson_26 as BSON_DATA_STRING, bson_25 as BSON_DATA_SYMBOL, bson_24 as BSON_DATA_TIMESTAMP, bson_23 as BSON_DATA_UNDEFINED, bson_22 as BSON_INT32_MAX, bson_21 as BSON_INT32_MIN, bson_20 as BSON_INT64_MAX, bson_19 as BSON_INT64_MIN, bson_12 as Binary, bson_16 as Code, bson_13 as DBRef, bson_2 as Decimal128, bson_7 as Double, bson_18 as EJSON, bson_6 as Int32, bson_9 as Long, bson_17 as LongWithoutOverridesClass, bson_15 as Map, bson_4 as MaxKey, bson_5 as MinKey, bson_1 as ObjectID, bson_11 as ObjectId, bson_8 as Timestamp, bson_10 as UUID, bson_52 as calculateObjectSize, bson_53 as deserialize, bson_51 as deserializeStream, bson_55 as serialize, bson_54 as serializeWithBufferAndIndex, bson_56 as setInternalBufferSize };
5335
+ export default BSON;
5336
+ export { BSONRegExp, BSONSymbol, BSON_BINARY_SUBTYPE_BYTE_ARRAY, BSON_BINARY_SUBTYPE_DEFAULT, BSON_BINARY_SUBTYPE_FUNCTION, BSON_BINARY_SUBTYPE_MD5, BSON_BINARY_SUBTYPE_USER_DEFINED, BSON_BINARY_SUBTYPE_UUID, BSON_BINARY_SUBTYPE_UUID_NEW, BSON_DATA_ARRAY, BSON_DATA_BINARY, BSON_DATA_BOOLEAN, BSON_DATA_CODE, BSON_DATA_CODE_W_SCOPE, BSON_DATA_DATE, BSON_DATA_DBPOINTER, BSON_DATA_DECIMAL128, BSON_DATA_INT, BSON_DATA_LONG, BSON_DATA_MAX_KEY, BSON_DATA_MIN_KEY, BSON_DATA_NULL, BSON_DATA_NUMBER, BSON_DATA_OBJECT, BSON_DATA_OID, BSON_DATA_REGEXP, BSON_DATA_STRING, BSON_DATA_SYMBOL, BSON_DATA_TIMESTAMP, BSON_DATA_UNDEFINED, BSON_INT32_MAX, BSON_INT32_MIN, BSON_INT64_MAX, BSON_INT64_MIN, Binary, Code, DBRef, Decimal128, Double, EJSON, Int32, Long, LongWithoutOverridesClass, bsonMap as Map, MaxKey, MinKey, ObjectId as ObjectID, ObjectId, Timestamp, UUID, calculateObjectSize, deserialize, deserializeStream, serialize, serializeWithBufferAndIndex, setInternalBufferSize };
6912
5337
  //# sourceMappingURL=bson.esm.js.map