From 9c8b0cf118b837882a47ee9407e1103e3dc0ed46 Mon Sep 17 00:00:00 2001 From: Jeff Nusz Date: Thu, 1 Sep 2016 16:06:25 -0700 Subject: [PATCH] clear up for..in loop eslint errors --- src/dat/utils/common.js | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/src/dat/utils/common.js b/src/dat/utils/common.js index 99a6733..c566019 100644 --- a/src/dat/utils/common.js +++ b/src/dat/utils/common.js @@ -25,10 +25,13 @@ const Common = { extend: function(target) { this.each(ARR_SLICE.call(arguments, 1), function(obj) { - for (const key in obj) { - if (!this.isUndefined(obj[key])) { - target[key] = obj[key]; - } + if (!this.isUndefined(obj)) { + const keys = Object.keys(obj); + keys.forEach(function(key) { + if (!this.isUndefined(obj[key])) { + target[key] = obj[key]; + } + }.bind(this)); } }, this); @@ -37,10 +40,13 @@ const Common = { defaults: function(target) { this.each(ARR_SLICE.call(arguments, 1), function(obj) { - for (const key in obj) { - if (this.isUndefined(target[key])) { - target[key] = obj[key]; - } + if (!this.isUndefined(obj)) { + const keys = Object.keys(obj); + keys.forEach(function(key) { + if (this.isUndefined(target[key])) { + target[key] = obj[key]; + } + }.bind(this)); } }, this); @@ -74,11 +80,14 @@ const Common = { } } } else { - for (const key in obj) { + if (this.isUndefined(obj)) return; + + const keys = Object.keys(obj); + keys.forEach(function(key) { if (itr.call(scope, obj[key], key) === this.BREAK) { return; } - } + }.bind(this)); } },