diff --git a/lib/aggregate.js b/lib/aggregate.js index 4d93251855f..746d7620b6d 100644 --- a/lib/aggregate.js +++ b/lib/aggregate.js @@ -11,7 +11,6 @@ const getConstructorName = require('./helpers/getConstructorName'); const prepareDiscriminatorPipeline = require('./helpers/aggregate/prepareDiscriminatorPipeline'); const promiseOrCallback = require('./helpers/promiseOrCallback'); const stringifyFunctionOperators = require('./helpers/aggregate/stringifyFunctionOperators'); -const util = require('util'); const utils = require('./utils'); const read = Query.prototype.read; const readConcern = Query.prototype.readConcern; @@ -55,7 +54,7 @@ function Aggregate(pipeline, model) { this._model = model; this.options = {}; - if (arguments.length === 1 && util.isArray(pipeline)) { + if (arguments.length === 1 && Array.isArray(pipeline)) { this.append.apply(this, pipeline); } } @@ -138,7 +137,7 @@ Aggregate.prototype.model = function(model) { */ Aggregate.prototype.append = function() { - const args = (arguments.length === 1 && util.isArray(arguments[0])) + const args = (arguments.length === 1 && Array.isArray(arguments[0])) ? arguments[0] : utils.args(arguments); @@ -176,7 +175,7 @@ Aggregate.prototype.append = function() { */ Aggregate.prototype.addFields = function(arg) { const fields = {}; - if (typeof arg === 'object' && !util.isArray(arg)) { + if (typeof arg === 'object' && !Array.isArray(arg)) { Object.keys(arg).forEach(function(field) { fields[field] = arg[field]; }); @@ -221,7 +220,7 @@ Aggregate.prototype.addFields = function(arg) { Aggregate.prototype.project = function(arg) { const fields = {}; - if (typeof arg === 'object' && !util.isArray(arg)) { + if (typeof arg === 'object' && !Array.isArray(arg)) { Object.keys(arg).forEach(function(field) { fields[field] = arg[field]; });