@@ -45,7 +45,7 @@ const manySpaceRE = /\s+/;
4545 * @api private
4646 */
4747
48- exports . toCollectionName = function ( name , pluralize ) {
48+ exports . toCollectionName = function ( name , pluralize ) {
4949 if ( name === 'system.profile' ) {
5050 return name ;
5151 }
@@ -89,19 +89,19 @@ exports.deepEqual = function deepEqual(a, b) {
8989 }
9090
9191 if ( ( isBsonType ( a , 'ObjectId' ) && isBsonType ( b , 'ObjectId' ) ) ||
92- ( isBsonType ( a , 'Decimal128' ) && isBsonType ( b , 'Decimal128' ) ) ) {
92+ ( isBsonType ( a , 'Decimal128' ) && isBsonType ( b , 'Decimal128' ) ) ) {
9393 return a . toString ( ) === b . toString ( ) ;
9494 }
9595
9696 if ( a instanceof RegExp && b instanceof RegExp ) {
9797 return a . source === b . source &&
98- a . ignoreCase === b . ignoreCase &&
99- a . multiline === b . multiline &&
100- a . global === b . global &&
101- a . dotAll === b . dotAll &&
102- a . unicode === b . unicode &&
103- a . sticky === b . sticky &&
104- a . hasIndices === b . hasIndices ;
98+ a . ignoreCase === b . ignoreCase &&
99+ a . multiline === b . multiline &&
100+ a . global === b . global &&
101+ a . dotAll === b . dotAll &&
102+ a . unicode === b . unicode &&
103+ a . sticky === b . sticky &&
104+ a . hasIndices === b . hasIndices ;
105105 }
106106
107107 if ( a == null || b == null ) {
@@ -190,7 +190,7 @@ exports.deepEqual = function deepEqual(a, b) {
190190 * @param {Array } arr
191191 */
192192
193- exports . last = function ( arr ) {
193+ exports . last = function ( arr ) {
194194 if ( arr . length > 0 ) {
195195 return arr [ arr . length - 1 ] ;
196196 }
@@ -287,8 +287,8 @@ exports.merge = function merge(to, from, options, path) {
287287 // base schema has a given path as a single nested but discriminator schema
288288 // has the path as a document array, or vice versa (gh-9534)
289289 if ( options . isDiscriminatorSchemaMerge &&
290- ( from [ key ] . $isSingleNested && to [ key ] . $isMongooseDocumentArray ) ||
291- ( from [ key ] . $isMongooseDocumentArray && to [ key ] . $isSingleNested ) ) {
290+ ( from [ key ] . $isSingleNested && to [ key ] . $isMongooseDocumentArray ) ||
291+ ( from [ key ] . $isMongooseDocumentArray && to [ key ] . $isSingleNested ) ) {
292292 continue ;
293293 } else if ( from [ key ] . instanceOfSchema ) {
294294 if ( to [ key ] . instanceOfSchema ) {
@@ -397,7 +397,7 @@ exports.isNonBuiltinObject = function isNonBuiltinObject(val) {
397397 * @param {Any } arg
398398 */
399399
400- exports . isNativeObject = function ( arg ) {
400+ exports . isNativeObject = function ( arg ) {
401401 return Array . isArray ( arg ) ||
402402 arg instanceof Date ||
403403 arg instanceof Boolean ||
@@ -410,7 +410,7 @@ exports.isNativeObject = function(arg) {
410410 * @param {Any } val
411411 */
412412
413- exports . isEmptyObject = function ( val ) {
413+ exports . isEmptyObject = function ( val ) {
414414 return val != null &&
415415 typeof val === 'object' &&
416416 Object . keys ( val ) . length === 0 ;
@@ -451,13 +451,13 @@ exports.tick = function tick(callback) {
451451 if ( typeof callback !== 'function' ) {
452452 return ;
453453 }
454- return function ( ) {
454+ return function ( ) {
455455 try {
456456 callback . apply ( this , arguments ) ;
457457 } catch ( err ) {
458458 // only nextTick on err to get out of
459459 // the event loop and avoid state corruption.
460- immediate ( function ( ) {
460+ immediate ( function ( ) {
461461 throw err ;
462462 } ) ;
463463 }
@@ -470,7 +470,7 @@ exports.tick = function tick(callback) {
470470 * @param {Any } v
471471 */
472472
473- exports . isMongooseType = function ( v ) {
473+ exports . isMongooseType = function ( v ) {
474474 return isBsonType ( v , 'ObjectId' ) || isBsonType ( v , 'Decimal128' ) || v instanceof Buffer ;
475475} ;
476476
@@ -562,10 +562,10 @@ exports.populate = function populate(path, select, model, match, options, subPop
562562 // an array, string, or object literal).
563563 function makeSingles ( arr ) {
564564 const ret = [ ] ;
565- arr . forEach ( function ( obj ) {
565+ arr . forEach ( function ( obj ) {
566566 if ( oneSpaceRE . test ( obj . path ) ) {
567567 const paths = obj . path . split ( manySpaceRE ) ;
568- paths . forEach ( function ( p ) {
568+ paths . forEach ( function ( p ) {
569569 const copy = Object . assign ( { } , obj ) ;
570570 copy . path = p ;
571571 ret . push ( copy ) ;
@@ -582,11 +582,11 @@ exports.populate = function populate(path, select, model, match, options, subPop
582582function _populateObj ( obj ) {
583583 if ( Array . isArray ( obj . populate ) ) {
584584 const ret = [ ] ;
585- obj . populate . forEach ( function ( obj ) {
585+ obj . populate . forEach ( function ( obj ) {
586586 if ( oneSpaceRE . test ( obj . path ) ) {
587587 const copy = Object . assign ( { } , obj ) ;
588588 const paths = copy . path . split ( manySpaceRE ) ;
589- paths . forEach ( function ( p ) {
589+ paths . forEach ( function ( p ) {
590590 copy . path = p ;
591591 ret . push ( exports . populate ( copy ) [ 0 ] ) ;
592592 } ) ;
@@ -620,7 +620,7 @@ function _populateObj(obj) {
620620 * @param {Any } map
621621 */
622622
623- exports . getValue = function ( path , obj , map ) {
623+ exports . getValue = function ( path , obj , map ) {
624624 return mpath . get ( path , obj , getValueLookup , map ) ;
625625} ;
626626
@@ -653,7 +653,7 @@ function getValueLookup(obj, part) {
653653 * @param {Any } _copying
654654 */
655655
656- exports . setValue = function ( path , val , obj , map , _copying ) {
656+ exports . setValue = function ( path , val , obj , map , _copying ) {
657657 mpath . set ( path , val , obj , '_doc' , map , _copying ) ;
658658} ;
659659
@@ -687,7 +687,7 @@ const hop = Object.prototype.hasOwnProperty;
687687 * @param {String } prop
688688 */
689689
690- exports . object . hasOwnProperty = function ( obj , prop ) {
690+ exports . object . hasOwnProperty = function ( obj , prop ) {
691691 return hop . call ( obj , prop ) ;
692692} ;
693693
@@ -698,7 +698,7 @@ exports.object.hasOwnProperty = function(obj, prop) {
698698 * @return {Boolean }
699699 */
700700
701- exports . isNullOrUndefined = function ( val ) {
701+ exports . isNullOrUndefined = function ( val ) {
702702 return val === null || val === undefined ;
703703} ;
704704
@@ -723,7 +723,7 @@ exports.array = {};
723723exports . array . flatten = function flatten ( arr , filter , ret ) {
724724 ret || ( ret = [ ] ) ;
725725
726- arr . forEach ( function ( item ) {
726+ arr . forEach ( function ( item ) {
727727 if ( Array . isArray ( item ) ) {
728728 flatten ( item , filter , ret ) ;
729729 } else {
@@ -742,7 +742,7 @@ exports.array.flatten = function flatten(arr, filter, ret) {
742742
743743const _hasOwnProperty = Object . prototype . hasOwnProperty ;
744744
745- exports . hasUserDefinedProperty = function ( obj , key ) {
745+ exports . hasUserDefinedProperty = function ( obj , key ) {
746746 if ( obj == null ) {
747747 return false ;
748748 }
@@ -773,7 +773,7 @@ exports.hasUserDefinedProperty = function(obj, key) {
773773
774774const MAX_ARRAY_INDEX = Math . pow ( 2 , 32 ) - 1 ;
775775
776- exports . isArrayIndex = function ( val ) {
776+ exports . isArrayIndex = function ( val ) {
777777 if ( typeof val === 'number' ) {
778778 return val >= 0 && val <= MAX_ARRAY_INDEX ;
779779 }
@@ -800,7 +800,7 @@ exports.isArrayIndex = function(val) {
800800 * @api private
801801 */
802802
803- exports . array . unique = function ( arr ) {
803+ exports . array . unique = function ( arr ) {
804804 const primitives = new Set ( ) ;
805805 const ids = new Set ( ) ;
806806 const ret = [ ] ;
@@ -835,7 +835,7 @@ exports.buffer = {};
835835 * @param {Object } b
836836 */
837837
838- exports . buffer . areEqual = function ( a , b ) {
838+ exports . buffer . areEqual = function ( a , b ) {
839839 if ( ! Buffer . isBuffer ( a ) ) {
840840 return false ;
841841 }
@@ -861,7 +861,7 @@ exports.getFunctionName = getFunctionName;
861861 * @param {Object } source
862862 */
863863
864- exports . decorate = function ( destination , source ) {
864+ exports . decorate = function ( destination , source ) {
865865 for ( const key in source ) {
866866 if ( specialProperties . has ( key ) ) {
867867 continue ;
@@ -878,7 +878,7 @@ exports.decorate = function(destination, source) {
878878 * @api private
879879 */
880880
881- exports . mergeClone = function ( to , fromObj ) {
881+ exports . mergeClone = function ( to , fromObj ) {
882882 if ( isMongooseObject ( fromObj ) ) {
883883 fromObj = fromObj . toObject ( {
884884 transform : false ,
@@ -943,7 +943,7 @@ exports.mergeClone = function(to, fromObj) {
943943 * @api private
944944 */
945945
946- exports . each = function ( arr , fn ) {
946+ exports . each = function ( arr , fn ) {
947947 for ( const item of arr ) {
948948 fn ( item ) ;
949949 }
@@ -957,7 +957,7 @@ exports.each = function(arr, fn) {
957957 * @param {String|Number } newKey
958958 * @api private
959959 */
960- exports . renameObjKey = function ( oldObj , oldKey , newKey ) {
960+ exports . renameObjKey = function ( oldObj , oldKey , newKey ) {
961961 const keys = Object . keys ( oldObj ) ;
962962 return keys . reduce (
963963 ( acc , val ) => {
@@ -976,7 +976,7 @@ exports.renameObjKey = function(oldObj, oldKey, newKey) {
976976 * ignore
977977 */
978978
979- exports . getOption = function ( name ) {
979+ exports . getOption = function ( name ) {
980980 const sources = Array . prototype . slice . call ( arguments , 1 ) ;
981981
982982 for ( const source of sources ) {
@@ -995,7 +995,7 @@ exports.getOption = function(name) {
995995 * ignore
996996 */
997997
998- exports . noop = function ( ) { } ;
998+ exports . noop = function ( ) { } ;
999999
10001000exports . errorToPOJO = function errorToPOJO ( error ) {
10011001 const isError = error instanceof Error ;
@@ -1025,3 +1025,13 @@ exports.injectTimestampsOption = function injectTimestampsOption(writeOperation,
10251025 }
10261026 writeOperation . timestamps = timestampsOption ;
10271027} ;
1028+
1029+ exports . print = function ( ...args ) {
1030+ const { inspect } = require ( 'util' ) ;
1031+ console . error (
1032+ inspect (
1033+ ...args ,
1034+ { depth : Infinity }
1035+ )
1036+ )
1037+ }
0 commit comments