Skip to content

Commit

Permalink
Merge pull request #11393 from Uzlopak/ArrayIsArray
Browse files Browse the repository at this point in the history
use everywhere Array.isArray instead of instanceof
  • Loading branch information
vkarpov15 committed Feb 15, 2022
2 parents d427563 + 96d2449 commit 7c46428
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions lib/document.js
Original file line number Diff line number Diff line change
Expand Up @@ -3107,7 +3107,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;
Expand Down Expand Up @@ -3310,7 +3310,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);
}, [])
Expand Down
2 changes: 1 addition & 1 deletion lib/model.js
Original file line number Diff line number Diff line change
Expand Up @@ -3163,7 +3163,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));
Expand Down
2 changes: 1 addition & 1 deletion lib/plugins/trackTransaction.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 &&
Expand Down

0 comments on commit 7c46428

Please sign in to comment.