From 8401a101279a8c909306787985a5e43a94202b4e Mon Sep 17 00:00:00 2001 From: pyoor Date: Thu, 8 Jun 2017 09:31:41 -0400 Subject: [PATCH] Replace instanceof Array checks with Array.isArray --- lib/random/random.js | 8 ++++---- lib/utils/block.js | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/random/random.js b/lib/random/random.js index df2905f..cac4191 100644 --- a/lib/random/random.js +++ b/lib/random/random.js @@ -50,7 +50,7 @@ var random = { // eslint-disable-line no-unused-vars return Math.exp(this.float() * Math.log(limit)) }, item: function (list) { - if (!(list instanceof Array || (list !== undefined && typeof list !== 'string' && list.hasOwnProperty('length')))) { + if (!(Array.isArray(list) || (list !== undefined && typeof list !== 'string' && list.hasOwnProperty('length')))) { logger.traceback() throw new TypeError('this.item() received a non array type: \'' + list + '\'') } @@ -70,7 +70,7 @@ var random = { // eslint-disable-line no-unused-vars if (typeof obj === 'function') { return obj() } - if (obj instanceof Array) { + if (Array.isArray(obj)) { return this.pick(this.item(obj)) } return obj @@ -86,7 +86,7 @@ var random = { // eslint-disable-line no-unused-vars return this.number(limit) === 1 }, choose: function (list, flat) { - if (!(list instanceof Array)) { + if (!(Array.isArray(list))) { logger.traceback() throw new TypeError('random.choose() received a non-array type: \'' + list + '\'') } @@ -138,7 +138,7 @@ var random = { // eslint-disable-line no-unused-vars return newArray }, subset: function (list, limit) { - if (!(list instanceof Array)) { + if (!(Array.isArray(list))) { logger.traceback() throw new TypeError('random.subset() received a non-array type: \'' + list + '\'') } diff --git a/lib/utils/block.js b/lib/utils/block.js index e756089..20ce3aa 100644 --- a/lib/utils/block.js +++ b/lib/utils/block.js @@ -20,7 +20,7 @@ utils.block = { if (typeof (item) === 'string') { return item } - if (item instanceof (Array)) { + if (Array.isArray(item)) { let s = '' for (let i = 0; i < item.length; i++) { s += deeper(item[i])