From 96d2449c8dc0ad734e824feea573153bf385c976 Mon Sep 17 00:00:00 2001 From: uzlopak Date: Mon, 14 Feb 2022 17:40:56 +0100 Subject: [PATCH] use everywhere Array.isArray instead of instanceof --- lib/document.js | 4 ++-- lib/model.js | 2 +- lib/plugins/trackTransaction.js | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/document.js b/lib/document.js index 8110d15f4c5..7219ffeb350 100644 --- a/lib/document.js +++ b/lib/document.js @@ -3105,7 +3105,7 @@ Document.prototype.$__reset = function reset() { return _this.$__getValue(i); }) .filter(function(val) { - return val && val instanceof Array && utils.isMongooseDocumentArray(val) && val.length; + return val && Array.isArray(val) && utils.isMongooseDocumentArray(val) && val.length; }) .forEach(function(array) { let i = array.length; @@ -3308,7 +3308,7 @@ Document.prototype.$__getArrayPathsToValidate = function() { return this.$__getValue(i); }.bind(this)) .filter(function(val) { - return val && val instanceof Array && utils.isMongooseDocumentArray(val) && val.length; + return val && Array.isArray(val) && utils.isMongooseDocumentArray(val) && val.length; }).reduce(function(seed, array) { return seed.concat(array); }, []) diff --git a/lib/model.js b/lib/model.js index 043dbba9bc1..338c4e508cf 100644 --- a/lib/model.js +++ b/lib/model.js @@ -3154,7 +3154,7 @@ Model.create = function create(doc, options, callback) { return cb(firstError, savedDocs); } - if (doc instanceof Array) { + if (Array.isArray(doc)) { cb(null, savedDocs); } else { cb.apply(this, [null].concat(savedDocs)); diff --git a/lib/plugins/trackTransaction.js b/lib/plugins/trackTransaction.js index 5a4b13f85f5..11444d16d45 100644 --- a/lib/plugins/trackTransaction.js +++ b/lib/plugins/trackTransaction.js @@ -47,7 +47,7 @@ function _getAtomics(doc, previous) { for (const path of pathsToCheck) { const val = doc.$__getValue(path); if (val != null && - val instanceof Array && + Array.isArray(val) && utils.isMongooseDocumentArray(val) && val.length && val[arrayAtomicsSymbol] != null &&