26 lines
502 B
JavaScript
26 lines
502 B
JavaScript
|
var Keys = require("object-keys")
|
||
|
var hasKeys = require("./has-keys")
|
||
|
|
||
|
module.exports = extend
|
||
|
|
||
|
function extend(target) {
|
||
|
var sources = [].slice.call(arguments, 1)
|
||
|
|
||
|
for (var i = 0; i < sources.length; i++) {
|
||
|
var source = sources[i]
|
||
|
|
||
|
if (!hasKeys(source)) {
|
||
|
continue
|
||
|
}
|
||
|
|
||
|
var keys = Keys(source)
|
||
|
|
||
|
for (var j = 0; j < keys.length; j++) {
|
||
|
var name = keys[j]
|
||
|
target[name] = source[name]
|
||
|
}
|
||
|
}
|
||
|
|
||
|
return target
|
||
|
}
|