Add production dependencies
This commit is contained in:
parent
5a0114f3e2
commit
579ccdc29f
12113 changed files with 978046 additions and 3 deletions
34
node_modules/es5-ext/object/assign-deep.js
generated
vendored
Normal file
34
node_modules/es5-ext/object/assign-deep.js
generated
vendored
Normal file
|
@ -0,0 +1,34 @@
|
|||
"use strict";
|
||||
|
||||
var includes = require("../array/#/contains")
|
||||
, uniq = require("../array/#/uniq")
|
||||
, copyDeep = require("./copy-deep")
|
||||
, objForEach = require("./for-each")
|
||||
, isPlainObject = require("./is-plain-object")
|
||||
, ensureValue = require("./valid-value");
|
||||
|
||||
var isArray = Array.isArray, slice = Array.prototype.slice;
|
||||
|
||||
var deepAssign = function (target, source) {
|
||||
if (target === source) return target;
|
||||
if (isPlainObject(target) && isPlainObject(source)) {
|
||||
objForEach(source, function (value, key) { target[key] = deepAssign(target[key], value); });
|
||||
return target;
|
||||
}
|
||||
if (isArray(target) && isArray(source)) {
|
||||
source.forEach(function (item) {
|
||||
if (includes.call(target, item)) return;
|
||||
if (isArray(item) || isPlainObject(item)) item = copyDeep(item);
|
||||
target.push(item);
|
||||
});
|
||||
return target;
|
||||
}
|
||||
if (isPlainObject(source) || isArray(source)) return copyDeep(source);
|
||||
return source;
|
||||
};
|
||||
|
||||
module.exports = function (target/*, ...objects*/) {
|
||||
return uniq
|
||||
.call([ensureValue(target)].concat(slice.call(arguments, 1).map(ensureValue)))
|
||||
.reduce(deepAssign);
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue