mirror of
https://github.com/dataarts/dat.gui.git
synced 2024-12-12 04:08:27 +00:00
cleaner ForEach loops in common.js
This commit is contained in:
parent
e63856cb14
commit
85ee981be4
@ -25,14 +25,12 @@ const Common = {
|
|||||||
|
|
||||||
extend: function(target) {
|
extend: function(target) {
|
||||||
this.each(ARR_SLICE.call(arguments, 1), function(obj) {
|
this.each(ARR_SLICE.call(arguments, 1), function(obj) {
|
||||||
if (!this.isUndefined(obj)) {
|
const keys = this.isObject(obj) ? Object.keys(obj) : [];
|
||||||
const keys = Object.keys(obj);
|
keys.forEach(function(key) {
|
||||||
keys.forEach(function(key) {
|
if (!this.isUndefined(obj[key])) {
|
||||||
if (!this.isUndefined(obj[key])) {
|
target[key] = obj[key];
|
||||||
target[key] = obj[key];
|
}
|
||||||
}
|
}.bind(this));
|
||||||
}.bind(this));
|
|
||||||
}
|
|
||||||
}, this);
|
}, this);
|
||||||
|
|
||||||
return target;
|
return target;
|
||||||
@ -40,14 +38,12 @@ const Common = {
|
|||||||
|
|
||||||
defaults: function(target) {
|
defaults: function(target) {
|
||||||
this.each(ARR_SLICE.call(arguments, 1), function(obj) {
|
this.each(ARR_SLICE.call(arguments, 1), function(obj) {
|
||||||
if (!this.isUndefined(obj)) {
|
const keys = this.isObject(obj) ? Object.keys(obj) : [];
|
||||||
const keys = Object.keys(obj);
|
keys.forEach(function(key) {
|
||||||
keys.forEach(function(key) {
|
if (this.isUndefined(target[key])) {
|
||||||
if (this.isUndefined(target[key])) {
|
target[key] = obj[key];
|
||||||
target[key] = obj[key];
|
}
|
||||||
}
|
}.bind(this));
|
||||||
}.bind(this));
|
|
||||||
}
|
|
||||||
}, this);
|
}, this);
|
||||||
|
|
||||||
return target;
|
return target;
|
||||||
@ -80,14 +76,11 @@ const Common = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (this.isUndefined(obj)) return;
|
for (const key in obj) {
|
||||||
|
|
||||||
const keys = Object.keys(obj);
|
|
||||||
keys.forEach(function(key) {
|
|
||||||
if (itr.call(scope, obj[key], key) === this.BREAK) {
|
if (itr.call(scope, obj[key], key) === this.BREAK) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}.bind(this));
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user