@@ -7308,7 +7308,8 @@ return /******/ (function(modules) { // webpackBootstrap
7308
7308
!(function(global) {
7309
7309
"use strict";
7310
7310
7311
- var hasOwn = Object.prototype.hasOwnProperty;
7311
+ var Op = Object.prototype;
7312
+ var hasOwn = Op.hasOwnProperty;
7312
7313
var undefined; // More compressible than void 0.
7313
7314
var $Symbol = typeof Symbol === "function" ? Symbol : {};
7314
7315
var iteratorSymbol = $Symbol.iterator || "@@iterator";
@@ -7380,10 +7381,29 @@ return /******/ (function(modules) { // webpackBootstrap
7380
7381
function GeneratorFunction() {}
7381
7382
function GeneratorFunctionPrototype() {}
7382
7383
7383
- var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype;
7384
+ // This is a polyfill for %IteratorPrototype% for environments that
7385
+ // don't natively support it.
7386
+ var IteratorPrototype = {};
7387
+ IteratorPrototype[iteratorSymbol] = function () {
7388
+ return this;
7389
+ };
7390
+
7391
+ var getProto = Object.getPrototypeOf;
7392
+ var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
7393
+ if (NativeIteratorPrototype &&
7394
+ NativeIteratorPrototype !== Op &&
7395
+ hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
7396
+ // This environment has a native %IteratorPrototype%; use it instead
7397
+ // of the polyfill.
7398
+ IteratorPrototype = NativeIteratorPrototype;
7399
+ }
7400
+
7401
+ var Gp = GeneratorFunctionPrototype.prototype =
7402
+ Generator.prototype = Object.create(IteratorPrototype);
7384
7403
GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype;
7385
7404
GeneratorFunctionPrototype.constructor = GeneratorFunction;
7386
- GeneratorFunctionPrototype[toStringTagSymbol] = GeneratorFunction.displayName = "GeneratorFunction";
7405
+ GeneratorFunctionPrototype[toStringTagSymbol] =
7406
+ GeneratorFunction.displayName = "GeneratorFunction";
7387
7407
7388
7408
// Helper for defining the .next, .throw, and .return methods of the
7389
7409
// Iterator interface in terms of a single ._invoke method.
@@ -7420,17 +7440,12 @@ return /******/ (function(modules) { // webpackBootstrap
7420
7440
7421
7441
// Within the body of any async function, `await x` is transformed to
7422
7442
// `yield regeneratorRuntime.awrap(x)`, so that the runtime can test
7423
- // `value instanceof AwaitArgument` to determine if the yielded value is
7424
- // meant to be awaited. Some may consider the name of this method too
7425
- // cutesy, but they are curmudgeons.
7443
+ // `hasOwn.call(value, "__await")` to determine if the yielded value is
7444
+ // meant to be awaited.
7426
7445
runtime.awrap = function(arg) {
7427
- return new AwaitArgument( arg) ;
7446
+ return { __await: arg } ;
7428
7447
};
7429
7448
7430
- function AwaitArgument(arg) {
7431
- this.arg = arg;
7432
- }
7433
-
7434
7449
function AsyncIterator(generator) {
7435
7450
function invoke(method, arg, resolve, reject) {
7436
7451
var record = tryCatch(generator[method], generator, arg);
@@ -7439,8 +7454,10 @@ return /******/ (function(modules) { // webpackBootstrap
7439
7454
} else {
7440
7455
var result = record.arg;
7441
7456
var value = result.value;
7442
- if (value instanceof AwaitArgument) {
7443
- return Promise.resolve(value.arg).then(function(value) {
7457
+ if (value &&
7458
+ typeof value === "object" &&
7459
+ hasOwn.call(value, "__await")) {
7460
+ return Promise.resolve(value.__await).then(function(value) {
7444
7461
invoke("next", value, resolve, reject);
7445
7462
}, function(err) {
7446
7463
invoke("throw", err, resolve, reject);
@@ -7509,6 +7526,7 @@ return /******/ (function(modules) { // webpackBootstrap
7509
7526
}
7510
7527
7511
7528
defineIteratorMethods(AsyncIterator.prototype);
7529
+ runtime.AsyncIterator = AsyncIterator;
7512
7530
7513
7531
// Note that simple async functions are implemented on top of
7514
7532
// AsyncIterator objects; they just return a Promise for the value of
@@ -7669,10 +7687,6 @@ return /******/ (function(modules) { // webpackBootstrap
7669
7687
// unified ._invoke helper method.
7670
7688
defineIteratorMethods(Gp);
7671
7689
7672
- Gp[iteratorSymbol] = function() {
7673
- return this;
7674
- };
7675
-
7676
7690
Gp[toStringTagSymbol] = "Generator";
7677
7691
7678
7692
Gp.toString = function() {
@@ -8291,11 +8305,6 @@ return /******/ (function(modules) { // webpackBootstrap
8291
8305
var serializeFunctions = typeof options.serializeFunctions == 'boolean' ? options.serializeFunctions : false;
8292
8306
var ignoreUndefined = typeof options.ignoreUndefined == 'boolean' ? options.ignoreUndefined : true;
8293
8307
8294
- // console.log("===================================== serialize")
8295
- // console.log("checkKeys = " + checkKeys)
8296
- // console.log("serializeFunctions = " + serializeFunctions)
8297
- // console.log("ignoreUndefined = " + ignoreUndefined)
8298
-
8299
8308
// Attempt to serialize
8300
8309
var serializationIndex = serializer(buffer, object, checkKeys, 0, 0, serializeFunctions, ignoreUndefined, []);
8301
8310
// Create the final buffer
@@ -8326,12 +8335,6 @@ return /******/ (function(modules) { // webpackBootstrap
8326
8335
var ignoreUndefined = typeof options.ignoreUndefined == 'boolean' ? options.ignoreUndefined : true;
8327
8336
var startIndex = typeof options.index == 'number' ? options.index : 0;
8328
8337
8329
- // console.log("===================================== serializeWithBufferAndIndex")
8330
- // console.log("checkKeys = " + checkKeys)
8331
- // console.log("serializeFunctions = " + serializeFunctions)
8332
- // console.log("ignoreUndefined = " + ignoreUndefined)
8333
- // console.log("startIndex = " + startIndex)
8334
-
8335
8338
// Attempt to serialize
8336
8339
var serializationIndex = serializer(buffer, object, checkKeys, startIndex || 0, 0, serializeFunctions, ignoreUndefined);
8337
8340
buffer.copy(finalBuffer, startIndex, 0, serializationIndex);
@@ -8343,20 +8346,20 @@ return /******/ (function(modules) { // webpackBootstrap
8343
8346
/**
8344
8347
* Deserialize data as BSON.
8345
8348
*
8346
- * Options
8347
- * - **evalFunctions** {Boolean, default:false}, evaluate functions in the BSON document scoped to the object deserialized.
8348
- * - **cacheFunctions** {Boolean, default:false}, cache evaluated functions for reuse.
8349
- * - **cacheFunctionsCrc32** {Boolean, default:false}, use a crc32 code for caching, otherwise use the string of the function.
8350
- * - **promoteLongs** {Boolean, default:true}, when deserializing a Long will fit it into a Number if it's smaller than 53 bits
8351
- *
8352
8349
* @param {Buffer} buffer the buffer containing the serialized set of BSON documents.
8353
- * @param {Object} [options] additional options used for the deserialization.
8354
- * @param {Boolean} [isArray] ignore used for recursive parsing.
8350
+ * @param {Object} [options.evalFunctions=false] evaluate functions in the BSON document scoped to the object deserialized.
8351
+ * @param {Object} [options.cacheFunctions=false] cache evaluated functions for reuse.
8352
+ * @param {Object} [options.cacheFunctionsCrc32=false] use a crc32 code for caching, otherwise use the string of the function.
8353
+ * @param {Object} [options.promoteLongs=true] when deserializing a Long will fit it into a Number if it's smaller than 53 bits
8354
+ * @param {Object} [options.promoteBuffers=false] when deserializing a Binary will return it as a node.js Buffer instance.
8355
+ * @param {Object} [options.promoteValues=false] when deserializing will promote BSON values to their Node.js closest equivalent types.
8356
+ * @param {Object} [options.fieldsAsRaw=null] allow to specify if there what fields we wish to return as unserialized raw buffer.
8357
+ * @param {Object} [options.bsonRegExp=false] return BSON regular expressions as BSONRegExp instances.
8355
8358
* @return {Object} returns the deserialized Javascript Object.
8356
8359
* @api public
8357
8360
*/
8358
- BSON.prototype.deserialize = function (data , options) {
8359
- return deserialize(data , options);
8361
+ BSON.prototype.deserialize = function (buffer , options) {
8362
+ return deserialize(buffer , options);
8360
8363
};
8361
8364
8362
8365
/**
@@ -8380,23 +8383,24 @@ return /******/ (function(modules) { // webpackBootstrap
8380
8383
/**
8381
8384
* Deserialize stream data as BSON documents.
8382
8385
*
8383
- * Options
8384
- * - **evalFunctions** {Boolean, default:false}, evaluate functions in the BSON document scoped to the object deserialized.
8385
- * - **cacheFunctions** {Boolean, default:false}, cache evaluated functions for reuse.
8386
- * - **cacheFunctionsCrc32** {Boolean, default:false}, use a crc32 code for caching, otherwise use the string of the function.
8387
- * - **promoteLongs** {Boolean, default:true}, when deserializing a Long will fit it into a Number if it's smaller than 53 bits
8388
- *
8389
8386
* @param {Buffer} data the buffer containing the serialized set of BSON documents.
8390
8387
* @param {Number} startIndex the start index in the data Buffer where the deserialization is to start.
8391
8388
* @param {Number} numberOfDocuments number of documents to deserialize.
8392
8389
* @param {Array} documents an array where to store the deserialized documents.
8393
8390
* @param {Number} docStartIndex the index in the documents array from where to start inserting documents.
8394
8391
* @param {Object} [options] additional options used for the deserialization.
8392
+ * @param {Object} [options.evalFunctions=false] evaluate functions in the BSON document scoped to the object deserialized.
8393
+ * @param {Object} [options.cacheFunctions=false] cache evaluated functions for reuse.
8394
+ * @param {Object} [options.cacheFunctionsCrc32=false] use a crc32 code for caching, otherwise use the string of the function.
8395
+ * @param {Object} [options.promoteLongs=true] when deserializing a Long will fit it into a Number if it's smaller than 53 bits
8396
+ * @param {Object} [options.promoteBuffers=false] when deserializing a Binary will return it as a node.js Buffer instance.
8397
+ * @param {Object} [options.promoteValues=false] when deserializing will promote BSON values to their Node.js closest equivalent types.
8398
+ * @param {Object} [options.fieldsAsRaw=null] allow to specify if there what fields we wish to return as unserialized raw buffer.
8399
+ * @param {Object} [options.bsonRegExp=false] return BSON regular expressions as BSONRegExp instances.
8395
8400
* @return {Number} returns the next index in the buffer after deserialization **x** numbers of documents.
8396
8401
* @api public
8397
8402
*/
8398
8403
BSON.prototype.deserializeStream = function (data, startIndex, numberOfDocuments, documents, docStartIndex, options) {
8399
- // if(numberOfDocuments !== documents.length) throw new Error("Number of expected results back is less than the number of documents");
8400
8404
options = options != null ? options : {};
8401
8405
var index = startIndex;
8402
8406
// Loop over all documents
@@ -8603,7 +8607,7 @@ return /******/ (function(modules) { // webpackBootstrap
8603
8607
/* 300 */
8604
8608
/***/ function(module, exports, __webpack_require__) {
8605
8609
8606
- /* WEBPACK VAR INJECTION */(function(Buffer, global) {/*!
8610
+ /* WEBPACK VAR INJECTION */(function(global) {/*!
8607
8611
* The buffer module from node.js, for the browser.
8608
8612
*
8609
8613
* @author Feross Aboukhadijeh <
[email protected] > <http://feross.org>
@@ -10393,7 +10397,7 @@ return /******/ (function(modules) { // webpackBootstrap
10393
10397
return val !== val // eslint-disable-line no-self-compare
10394
10398
}
10395
10399
10396
- /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(300).Buffer, (function() { return this; }())))
10400
+ /* WEBPACK VAR INJECTION */}.call(exports, (function() { return this; }())))
10397
10401
10398
10402
/***/ },
10399
10403
/* 301 */
@@ -12626,7 +12630,7 @@ return /******/ (function(modules) { // webpackBootstrap
12626
12630
/* 309 */
12627
12631
/***/ function(module, exports, __webpack_require__) {
12628
12632
12629
- /* WEBPACK VAR INJECTION */(function(process, Buffer ) {/**
12633
+ /* WEBPACK VAR INJECTION */(function(Buffer, process ) {/**
12630
12634
* Machine id.
12631
12635
*
12632
12636
* Create a random 3-byte value (i.e. unique for this
@@ -12638,6 +12642,12 @@ return /******/ (function(modules) { // webpackBootstrap
12638
12642
12639
12643
// Regular expression that checks for hex value
12640
12644
var checkForHexRegExp = new RegExp("^[0-9a-fA-F]{24}$");
12645
+ var hasBufferType = false;
12646
+
12647
+ // Check if buffer exists
12648
+ try {
12649
+ if (Buffer && Buffer.from) hasBufferType = true;
12650
+ } catch (err) {};
12641
12651
12642
12652
/**
12643
12653
* Create a new ObjectID instance
@@ -12654,17 +12664,26 @@ return /******/ (function(modules) { // webpackBootstrap
12654
12664
12655
12665
this._bsontype = 'ObjectID';
12656
12666
12657
- var __id = null;
12667
+ // The most common usecase (blank id, new objectId instance)
12668
+ if (id == null || typeof id == 'number') {
12669
+ // Generate a new id
12670
+ this.id = this.generate(id);
12671
+ // If we are caching the hex string
12672
+ if (ObjectID.cacheHexString) this.__id = this.toString('hex');
12673
+ // Return the object
12674
+ return;
12675
+ }
12676
+
12677
+ // Check if the passed in id is valid
12658
12678
var valid = ObjectID.isValid(id);
12659
12679
12660
12680
// Throw an error if it's not a valid setup
12661
12681
if (!valid && id != null) {
12662
12682
throw new Error("Argument passed in must be a single String of 12 bytes or a string of 24 hex characters");
12683
+ } else if (valid && typeof id == 'string' && id.length == 24 && hasBufferType) {
12684
+ return new ObjectID(new Buffer(id, 'hex'));
12663
12685
} else if (valid && typeof id == 'string' && id.length == 24) {
12664
12686
return ObjectID.createFromHexString(id);
12665
- } else if (id == null || typeof id == 'number') {
12666
- // convert to 12 byte binary string
12667
- this.id = this.generate(id);
12668
12687
} else if (id != null && id.length === 12) {
12669
12688
// assume 12 byte string
12670
12689
this.id = id;
@@ -12675,7 +12694,7 @@ return /******/ (function(modules) { // webpackBootstrap
12675
12694
throw new Error("Argument passed in must be a single String of 12 bytes or a string of 24 hex characters");
12676
12695
}
12677
12696
12678
- if (ObjectID.cacheHexString) this.__id = this.toHexString( );
12697
+ if (ObjectID.cacheHexString) this.__id = this.toString('hex' );
12679
12698
};
12680
12699
12681
12700
// Allow usage of ObjectId as well as ObjectID
@@ -12777,10 +12796,17 @@ return /******/ (function(modules) { // webpackBootstrap
12777
12796
/**
12778
12797
* Converts the id into a 24 byte hex string for printing
12779
12798
*
12799
+ * @param {String} format The Buffer toString format parameter.
12780
12800
* @return {String} return the 24 byte hex string representation.
12781
12801
* @ignore
12782
12802
*/
12783
- ObjectID.prototype.toString = function () {
12803
+ ObjectID.prototype.toString = function (format) {
12804
+ // Is the id a buffer then use the buffer toString method to return the format
12805
+ if (this.id && this.id.copy) {
12806
+ return this.id.toString(typeof format === 'string' ? format : 'hex');
12807
+ }
12808
+
12809
+ // if(this.buffer )
12784
12810
return this.toHexString();
12785
12811
};
12786
12812
@@ -12891,21 +12917,19 @@ return /******/ (function(modules) { // webpackBootstrap
12891
12917
*/
12892
12918
ObjectID.createFromHexString = function createFromHexString(string) {
12893
12919
// Throw an error if it's not a valid setup
12894
- if (typeof string === 'undefined' || string != null && string.length != 24) throw new Error("Argument passed in must be a single String of 12 bytes or a string of 24 hex characters");
12895
-
12896
- var length = string.length;
12897
-
12898
- if (length > 12 * 2) {
12899
- throw new Error('Id cannot be longer than 12 bytes');
12920
+ if (typeof string === 'undefined' || string != null && string.length != 24) {
12921
+ throw new Error("Argument passed in must be a single String of 12 bytes or a string of 24 hex characters");
12900
12922
}
12901
12923
12924
+ // Use Buffer.from method if available
12925
+ if (hasBufferType) return new ObjectID(new Buffer(string, 'hex'));
12926
+
12902
12927
// Calculate lengths
12903
- var sizeof = length >> 1;
12904
- var array = new _Buffer(sizeof);
12928
+ var array = new _Buffer(12);
12905
12929
var n = 0;
12906
12930
var i = 0;
12907
12931
12908
- while (i < length ) {
12932
+ while (i < 24 ) {
12909
12933
array[n++] = decodeLookup[string.charCodeAt(i++)] << 4 | decodeLookup[string.charCodeAt(i++)];
12910
12934
}
12911
12935
@@ -12968,7 +12992,7 @@ return /******/ (function(modules) { // webpackBootstrap
12968
12992
module.exports = ObjectID;
12969
12993
module.exports.ObjectID = ObjectID;
12970
12994
module.exports.ObjectId = ObjectID;
12971
- /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(294) , __webpack_require__(300).Buffer ))
12995
+ /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(300).Buffer , __webpack_require__(294) ))
12972
12996
12973
12997
/***/ },
12974
12998
/* 310 */
@@ -15683,17 +15707,6 @@ return /******/ (function(modules) { // webpackBootstrap
15683
15707
return index;
15684
15708
};
15685
15709
15686
- var serializeUndefined = function (buffer, key, value, index, isArray) {
15687
- // Set long type
15688
- buffer[index++] = BSON.BSON_DATA_UNDEFINED;
15689
- // Number of written bytes
15690
- var numberOfWrittenBytes = !isArray ? buffer.write(key, index, 'utf8') : buffer.write(key, index, 'ascii');
15691
- // Encode the name
15692
- index = index + numberOfWrittenBytes;
15693
- buffer[index++] = 0;
15694
- return index;
15695
- };
15696
-
15697
15710
var serializeNull = function (buffer, key, value, index, isArray) {
15698
15711
// Set long type
15699
15712
buffer[index++] = BSON.BSON_DATA_NULL;
@@ -16252,9 +16265,7 @@ return /******/ (function(modules) { // webpackBootstrap
16252
16265
index = serializeBoolean(buffer, key, value, index);
16253
16266
} else if (value instanceof Date || isDate(value)) {
16254
16267
index = serializeDate(buffer, key, value, index);
16255
- } else if (value === undefined && ignoreUndefined == true) {} else if (value === undefined) {
16256
- index = serializeUndefined(buffer, key, value, index);
16257
- } else if (value === null) {
16268
+ } else if (value === undefined && ignoreUndefined == true) {} else if (value === null || value === undefined) {
16258
16269
index = serializeNull(buffer, key, value, index);
16259
16270
} else if (value['_bsontype'] == 'ObjectID') {
16260
16271
index = serializeObjectId(buffer, key, value, index);
@@ -16333,9 +16344,7 @@ return /******/ (function(modules) { // webpackBootstrap
16333
16344
index = serializeBoolean(buffer, key, value, index);
16334
16345
} else if (value instanceof Date || isDate(value)) {
16335
16346
index = serializeDate(buffer, key, value, index);
16336
- } else if (value === undefined && ignoreUndefined == true) {} else if (value === undefined) {
16337
- index = serializeUndefined(buffer, key, value, index);
16338
- } else if (value === null) {
16347
+ } else if (value === undefined && ignoreUndefined == true) {} else if (value === null || value === undefined) {
16339
16348
index = serializeNull(buffer, key, value, index);
16340
16349
} else if (value['_bsontype'] == 'ObjectID') {
16341
16350
index = serializeObjectId(buffer, key, value, index);
0 commit comments