You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
576 B
34 lines
576 B
1 month ago
|
'use strict';
|
||
|
|
||
|
var isObject = require('is-extendable');
|
||
|
|
||
|
module.exports = function extend(o/*, objects*/) {
|
||
|
if (!isObject(o)) { o = {}; }
|
||
|
|
||
|
var len = arguments.length;
|
||
|
for (var i = 1; i < len; i++) {
|
||
|
var obj = arguments[i];
|
||
|
|
||
|
if (isObject(obj)) {
|
||
|
assign(o, obj);
|
||
|
}
|
||
|
}
|
||
|
return o;
|
||
|
};
|
||
|
|
||
|
function assign(a, b) {
|
||
|
for (var key in b) {
|
||
|
if (hasOwn(b, key)) {
|
||
|
a[key] = b[key];
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Returns true if the given `key` is an own property of `obj`.
|
||
|
*/
|
||
|
|
||
|
function hasOwn(obj, key) {
|
||
|
return Object.prototype.hasOwnProperty.call(obj, key);
|
||
|
}
|