--
This commit is contained in:
parent
24f3d27984
commit
6b60015c02
9588 changed files with 1149251 additions and 49 deletions
56
node_modules/deep-assign/index.js
generated
vendored
Normal file
56
node_modules/deep-assign/index.js
generated
vendored
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
'use strict';
|
||||
var isObj = require('is-obj');
|
||||
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
||||
var propIsEnumerable = Object.prototype.propertyIsEnumerable;
|
||||
|
||||
function toObject(val) {
|
||||
if (val === null || val === undefined) {
|
||||
throw new TypeError('Sources cannot be null or undefined');
|
||||
}
|
||||
|
||||
return Object(val);
|
||||
}
|
||||
|
||||
function base(to, from) {
|
||||
if (to === from) {
|
||||
return to;
|
||||
}
|
||||
|
||||
from = Object(from);
|
||||
|
||||
for (var key in from) {
|
||||
if (hasOwnProperty.call(from, key)) {
|
||||
var val = from[key];
|
||||
|
||||
if (Array.isArray(val)) {
|
||||
to[key] = val.slice();
|
||||
} else if (isObj(val)) {
|
||||
to[key] = base(to[key] || {}, val);
|
||||
} else if (val !== undefined) {
|
||||
to[key] = val;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (Object.getOwnPropertySymbols) {
|
||||
var symbols = Object.getOwnPropertySymbols(from);
|
||||
|
||||
for (var i = 0; i < symbols.length; i++) {
|
||||
if (propIsEnumerable.call(from, symbols[i])) {
|
||||
to[symbols[i]] = from[symbols[i]];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return to;
|
||||
}
|
||||
|
||||
module.exports = function deepAssign(target) {
|
||||
target = toObject(target);
|
||||
|
||||
for (var s = 1; s < arguments.length; s++) {
|
||||
base(target, arguments[s]);
|
||||
}
|
||||
|
||||
return target;
|
||||
};
|
||||
Loading…
Reference in a new issue