lodash.mergewith
Advanced tools
Comparing version 4.2.0 to 4.3.0
558
index.js
/** | ||
* lodash 4.2.0 (Custom Build) <https://lodash.com/> | ||
* lodash 4.3.0 (Custom Build) <https://lodash.com/> | ||
* Build: `lodash modularize exports="npm" -o ./` | ||
@@ -10,9 +10,6 @@ * Copyright 2012-2016 The Dojo Foundation <http://dojofoundation.org/> | ||
var Stack = require('lodash._stack'), | ||
baseFor = require('lodash._basefor'), | ||
isBuffer = require('lodash.isbuffer'), | ||
baseClone = require('lodash._baseclone'), | ||
isPlainObject = require('lodash.isplainobject'), | ||
keys = require('lodash.keys'), | ||
keysIn = require('lodash.keysin'), | ||
rest = require('lodash.rest'), | ||
root = require('lodash._root'); | ||
rest = require('lodash.rest'); | ||
@@ -36,3 +33,2 @@ /** Used as references for various `Number` constants. */ | ||
stringTag = '[object String]', | ||
symbolTag = '[object Symbol]', | ||
weakMapTag = '[object WeakMap]'; | ||
@@ -51,11 +47,2 @@ | ||
/** Used to match `RegExp` [syntax characters](http://ecma-international.org/ecma-262/6.0/#sec-patterns). */ | ||
var reRegExpChar = /[\\^$.*+?()[\]{}|]/g; | ||
/** Used to match `RegExp` flags from their coerced string values. */ | ||
var reFlags = /\w*$/; | ||
/** Used to detect host constructors (Safari > 5). */ | ||
var reIsHostCtor = /^\[object .+?Constructor\]$/; | ||
/** Used to detect unsigned integer values. */ | ||
@@ -79,45 +66,3 @@ var reIsUint = /^(?:0|[1-9]\d*)$/; | ||
/** Used to identify `toStringTag` values supported by `_.clone`. */ | ||
var cloneableTags = {}; | ||
cloneableTags[argsTag] = cloneableTags[arrayTag] = | ||
cloneableTags[arrayBufferTag] = cloneableTags[boolTag] = | ||
cloneableTags[dateTag] = cloneableTags[float32Tag] = | ||
cloneableTags[float64Tag] = cloneableTags[int8Tag] = | ||
cloneableTags[int16Tag] = cloneableTags[int32Tag] = | ||
cloneableTags[mapTag] = cloneableTags[numberTag] = | ||
cloneableTags[objectTag] = cloneableTags[regexpTag] = | ||
cloneableTags[setTag] = cloneableTags[stringTag] = | ||
cloneableTags[symbolTag] = cloneableTags[uint8Tag] = | ||
cloneableTags[uint8ClampedTag] = cloneableTags[uint16Tag] = | ||
cloneableTags[uint32Tag] = true; | ||
cloneableTags[errorTag] = cloneableTags[funcTag] = | ||
cloneableTags[weakMapTag] = false; | ||
/** | ||
* Adds the key-value `pair` to `map`. | ||
* | ||
* @private | ||
* @param {Object} map The map to modify. | ||
* @param {Array} pair The key-value pair to add. | ||
* @returns {Object} Returns `map`. | ||
*/ | ||
function addMapEntry(map, pair) { | ||
map.set(pair[0], pair[1]); | ||
return map; | ||
} | ||
/** | ||
* Adds `value` to `set`. | ||
* | ||
* @private | ||
* @param {Object} set The set to modify. | ||
* @param {*} value The value to add. | ||
* @returns {Object} Returns `set`. | ||
*/ | ||
function addSetEntry(set, value) { | ||
set.add(value); | ||
return set; | ||
} | ||
/** | ||
* A specialized version of `_.forEach` for arrays without support for | ||
@@ -144,45 +89,2 @@ * iteratee shorthands. | ||
/** | ||
* A specialized version of `_.reduce` for arrays without support for | ||
* iteratee shorthands. | ||
* | ||
* @private | ||
* @param {Array} array The array to iterate over. | ||
* @param {Function} iteratee The function invoked per iteration. | ||
* @param {*} [accumulator] The initial value. | ||
* @param {boolean} [initAccum] Specify using the first element of `array` as the initial value. | ||
* @returns {*} Returns the accumulated value. | ||
*/ | ||
function arrayReduce(array, iteratee, accumulator, initAccum) { | ||
var index = -1, | ||
length = array.length; | ||
if (initAccum && length) { | ||
accumulator = array[++index]; | ||
} | ||
while (++index < length) { | ||
accumulator = iteratee(accumulator, array[index], index, array); | ||
} | ||
return accumulator; | ||
} | ||
/** | ||
* Checks if `value` is a host object in IE < 9. | ||
* | ||
* @private | ||
* @param {*} value The value to check. | ||
* @returns {boolean} Returns `true` if `value` is a host object, else `false`. | ||
*/ | ||
function isHostObject(value) { | ||
// Many host objects are `Object` objects that can coerce to strings | ||
// despite having improperly defined `toString` methods. | ||
var result = false; | ||
if (value != null && typeof value.toString != 'function') { | ||
try { | ||
result = !!(value + ''); | ||
} catch (e) {} | ||
} | ||
return result; | ||
} | ||
/** | ||
* Checks if `value` is a valid array-like index. | ||
@@ -201,42 +103,5 @@ * | ||
/** | ||
* Converts `map` to an array. | ||
* | ||
* @private | ||
* @param {Object} map The map to convert. | ||
* @returns {Array} Returns the converted array. | ||
*/ | ||
function mapToArray(map) { | ||
var index = -1, | ||
result = Array(map.size); | ||
map.forEach(function(value, key) { | ||
result[++index] = [key, value]; | ||
}); | ||
return result; | ||
} | ||
/** | ||
* Converts `set` to an array. | ||
* | ||
* @private | ||
* @param {Object} set The set to convert. | ||
* @returns {Array} Returns the converted array. | ||
*/ | ||
function setToArray(set) { | ||
var index = -1, | ||
result = Array(set.size); | ||
set.forEach(function(value) { | ||
result[++index] = value; | ||
}); | ||
return result; | ||
} | ||
/** Used for built-in method references. */ | ||
var objectProto = Object.prototype; | ||
/** Used to resolve the decompiled source of functions. */ | ||
var funcToString = Function.prototype.toString; | ||
/** Used to check objects for own properties. */ | ||
@@ -251,29 +116,5 @@ var hasOwnProperty = objectProto.hasOwnProperty; | ||
/** Used to detect if a method is native. */ | ||
var reIsNative = RegExp('^' + | ||
funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&') | ||
.replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$' | ||
); | ||
/** Built-in value references. */ | ||
var Symbol = root.Symbol, | ||
Uint8Array = root.Uint8Array, | ||
getOwnPropertySymbols = Object.getOwnPropertySymbols, | ||
objectCreate = Object.create, | ||
propertyIsEnumerable = objectProto.propertyIsEnumerable; | ||
var propertyIsEnumerable = objectProto.propertyIsEnumerable; | ||
/* Built-in method references that are verified to be native. */ | ||
var Map = getNative(root, 'Map'), | ||
Set = getNative(root, 'Set'), | ||
WeakMap = getNative(root, 'WeakMap'); | ||
/** Used to detect maps, sets, and weakmaps. */ | ||
var mapCtorString = Map ? funcToString.call(Map) : '', | ||
setCtorString = Set ? funcToString.call(Set) : '', | ||
weakMapCtorString = WeakMap ? funcToString.call(WeakMap) : ''; | ||
/** Used to convert symbols to primitives and strings. */ | ||
var symbolProto = Symbol ? Symbol.prototype : undefined, | ||
symbolValueOf = Symbol ? symbolProto.valueOf : undefined; | ||
/** | ||
@@ -314,105 +155,2 @@ * This function is like `assignValue` except that it doesn't assign `undefined` values. | ||
/** | ||
* The base implementation of `_.assign` without support for multiple sources | ||
* or `customizer` functions. | ||
* | ||
* @private | ||
* @param {Object} object The destination object. | ||
* @param {Object} source The source object. | ||
* @returns {Object} Returns `object`. | ||
*/ | ||
function baseAssign(object, source) { | ||
return object && copyObject(source, keys(source), object); | ||
} | ||
/** | ||
* The base implementation of `_.clone` and `_.cloneDeep` which tracks | ||
* traversed objects. | ||
* | ||
* @private | ||
* @param {*} value The value to clone. | ||
* @param {boolean} [isDeep] Specify a deep clone. | ||
* @param {Function} [customizer] The function to customize cloning. | ||
* @param {string} [key] The key of `value`. | ||
* @param {Object} [object] The parent object of `value`. | ||
* @param {Object} [stack] Tracks traversed objects and their clone counterparts. | ||
* @returns {*} Returns the cloned value. | ||
*/ | ||
function baseClone(value, isDeep, customizer, key, object, stack) { | ||
var result; | ||
if (customizer) { | ||
result = object ? customizer(value, key, object, stack) : customizer(value); | ||
} | ||
if (result !== undefined) { | ||
return result; | ||
} | ||
if (!isObject(value)) { | ||
return value; | ||
} | ||
var isArr = isArray(value); | ||
if (isArr) { | ||
result = initCloneArray(value); | ||
if (!isDeep) { | ||
return copyArray(value, result); | ||
} | ||
} else { | ||
var tag = getTag(value), | ||
isFunc = tag == funcTag || tag == genTag; | ||
if (isBuffer(value)) { | ||
return cloneBuffer(value, isDeep); | ||
} | ||
if (tag == objectTag || tag == argsTag || (isFunc && !object)) { | ||
if (isHostObject(value)) { | ||
return object ? value : {}; | ||
} | ||
result = initCloneObject(isFunc ? {} : value); | ||
if (!isDeep) { | ||
return copySymbols(value, baseAssign(result, value)); | ||
} | ||
} else { | ||
return cloneableTags[tag] | ||
? initCloneByTag(value, tag, isDeep) | ||
: (object ? value : {}); | ||
} | ||
} | ||
// Check for circular references and return its corresponding clone. | ||
stack || (stack = new Stack); | ||
var stacked = stack.get(value); | ||
if (stacked) { | ||
return stacked; | ||
} | ||
stack.set(value, result); | ||
// Recursively populate clone (susceptible to call stack limits). | ||
(isArr ? arrayEach : baseForOwn)(value, function(subValue, key) { | ||
assignValue(result, key, baseClone(subValue, isDeep, customizer, key, value, stack)); | ||
}); | ||
return isArr ? result : copySymbols(value, result); | ||
} | ||
/** | ||
* The base implementation of `_.create` without support for assigning | ||
* properties to the created object. | ||
* | ||
* @private | ||
* @param {Object} prototype The object to inherit from. | ||
* @returns {Object} Returns the new object. | ||
*/ | ||
function baseCreate(proto) { | ||
return isObject(proto) ? objectCreate(proto) : {}; | ||
} | ||
/** | ||
* The base implementation of `_.forOwn` without support for iteratee shorthands. | ||
* | ||
* @private | ||
* @param {Object} object The object to iterate over. | ||
* @param {Function} iteratee The function invoked per iteration. | ||
* @returns {Object} Returns `object`. | ||
*/ | ||
function baseForOwn(object, iteratee) { | ||
return object && baseFor(object, iteratee, keys); | ||
} | ||
/** | ||
* The base implementation of `_.merge` without support for multiple sources. | ||
@@ -539,103 +277,2 @@ * | ||
/** | ||
* Creates a clone of `buffer`. | ||
* | ||
* @private | ||
* @param {Buffer} buffer The buffer to clone. | ||
* @param {boolean} [isDeep] Specify a deep clone. | ||
* @returns {Buffer} Returns the cloned buffer. | ||
*/ | ||
function cloneBuffer(buffer, isDeep) { | ||
if (isDeep) { | ||
return buffer.slice(); | ||
} | ||
var Ctor = buffer.constructor, | ||
result = new Ctor(buffer.length); | ||
buffer.copy(result); | ||
return result; | ||
} | ||
/** | ||
* Creates a clone of `arrayBuffer`. | ||
* | ||
* @private | ||
* @param {ArrayBuffer} arrayBuffer The array buffer to clone. | ||
* @returns {ArrayBuffer} Returns the cloned array buffer. | ||
*/ | ||
function cloneArrayBuffer(arrayBuffer) { | ||
var Ctor = arrayBuffer.constructor, | ||
result = new Ctor(arrayBuffer.byteLength), | ||
view = new Uint8Array(result); | ||
view.set(new Uint8Array(arrayBuffer)); | ||
return result; | ||
} | ||
/** | ||
* Creates a clone of `map`. | ||
* | ||
* @private | ||
* @param {Object} map The map to clone. | ||
* @returns {Object} Returns the cloned map. | ||
*/ | ||
function cloneMap(map) { | ||
var Ctor = map.constructor; | ||
return arrayReduce(mapToArray(map), addMapEntry, new Ctor); | ||
} | ||
/** | ||
* Creates a clone of `regexp`. | ||
* | ||
* @private | ||
* @param {Object} regexp The regexp to clone. | ||
* @returns {Object} Returns the cloned regexp. | ||
*/ | ||
function cloneRegExp(regexp) { | ||
var Ctor = regexp.constructor, | ||
result = new Ctor(regexp.source, reFlags.exec(regexp)); | ||
result.lastIndex = regexp.lastIndex; | ||
return result; | ||
} | ||
/** | ||
* Creates a clone of `set`. | ||
* | ||
* @private | ||
* @param {Object} set The set to clone. | ||
* @returns {Object} Returns the cloned set. | ||
*/ | ||
function cloneSet(set) { | ||
var Ctor = set.constructor; | ||
return arrayReduce(setToArray(set), addSetEntry, new Ctor); | ||
} | ||
/** | ||
* Creates a clone of the `symbol` object. | ||
* | ||
* @private | ||
* @param {Object} symbol The symbol object to clone. | ||
* @returns {Object} Returns the cloned symbol object. | ||
*/ | ||
function cloneSymbol(symbol) { | ||
return Symbol ? Object(symbolValueOf.call(symbol)) : {}; | ||
} | ||
/** | ||
* Creates a clone of `typedArray`. | ||
* | ||
* @private | ||
* @param {Object} typedArray The typed array to clone. | ||
* @param {boolean} [isDeep] Specify a deep clone. | ||
* @returns {Object} Returns the cloned typed array. | ||
*/ | ||
function cloneTypedArray(typedArray, isDeep) { | ||
var arrayBuffer = typedArray.buffer, | ||
buffer = isDeep ? cloneArrayBuffer(arrayBuffer) : arrayBuffer, | ||
Ctor = typedArray.constructor; | ||
return new Ctor(buffer, typedArray.byteOffset, typedArray.length); | ||
} | ||
/** | ||
* Copies the values of `source` to `array`. | ||
@@ -702,14 +339,2 @@ * | ||
/** | ||
* Copies own symbol properties of `source` to `object`. | ||
* | ||
* @private | ||
* @param {Object} source The object to copy symbols from. | ||
* @param {Object} [object={}] The object to copy symbols to. | ||
* @returns {Object} Returns `object`. | ||
*/ | ||
function copySymbols(source, object) { | ||
return copyObject(source, getSymbols(source), object); | ||
} | ||
/** | ||
* Creates a function like `_.assign`. | ||
@@ -760,136 +385,2 @@ * | ||
/** | ||
* Gets the native function at `key` of `object`. | ||
* | ||
* @private | ||
* @param {Object} object The object to query. | ||
* @param {string} key The key of the method to get. | ||
* @returns {*} Returns the function if it's native, else `undefined`. | ||
*/ | ||
function getNative(object, key) { | ||
var value = object == null ? undefined : object[key]; | ||
return isNative(value) ? value : undefined; | ||
} | ||
/** | ||
* Creates an array of the own symbol properties of `object`. | ||
* | ||
* @private | ||
* @param {Object} object The object to query. | ||
* @returns {Array} Returns the array of symbols. | ||
*/ | ||
var getSymbols = getOwnPropertySymbols || function() { | ||
return []; | ||
}; | ||
/** | ||
* Gets the `toStringTag` of `value`. | ||
* | ||
* @private | ||
* @param {*} value The value to query. | ||
* @returns {string} Returns the `toStringTag`. | ||
*/ | ||
function getTag(value) { | ||
return objectToString.call(value); | ||
} | ||
// Fallback for IE 11 providing `toStringTag` values for maps, sets, and weakmaps. | ||
if ((Map && getTag(new Map) != mapTag) || | ||
(Set && getTag(new Set) != setTag) || | ||
(WeakMap && getTag(new WeakMap) != weakMapTag)) { | ||
getTag = function(value) { | ||
var result = objectToString.call(value), | ||
Ctor = result == objectTag ? value.constructor : null, | ||
ctorString = typeof Ctor == 'function' ? funcToString.call(Ctor) : ''; | ||
if (ctorString) { | ||
switch (ctorString) { | ||
case mapCtorString: return mapTag; | ||
case setCtorString: return setTag; | ||
case weakMapCtorString: return weakMapTag; | ||
} | ||
} | ||
return result; | ||
}; | ||
} | ||
/** | ||
* Initializes an array clone. | ||
* | ||
* @private | ||
* @param {Array} array The array to clone. | ||
* @returns {Array} Returns the initialized clone. | ||
*/ | ||
function initCloneArray(array) { | ||
var length = array.length, | ||
result = array.constructor(length); | ||
// Add properties assigned by `RegExp#exec`. | ||
if (length && typeof array[0] == 'string' && hasOwnProperty.call(array, 'index')) { | ||
result.index = array.index; | ||
result.input = array.input; | ||
} | ||
return result; | ||
} | ||
/** | ||
* Initializes an object clone. | ||
* | ||
* @private | ||
* @param {Object} object The object to clone. | ||
* @returns {Object} Returns the initialized clone. | ||
*/ | ||
function initCloneObject(object) { | ||
if (isPrototype(object)) { | ||
return {}; | ||
} | ||
var Ctor = object.constructor; | ||
return baseCreate(isFunction(Ctor) ? Ctor.prototype : undefined); | ||
} | ||
/** | ||
* Initializes an object clone based on its `toStringTag`. | ||
* | ||
* **Note:** This function only supports cloning values with tags of | ||
* `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`. | ||
* | ||
* @private | ||
* @param {Object} object The object to clone. | ||
* @param {string} tag The `toStringTag` of the object to clone. | ||
* @param {boolean} [isDeep] Specify a deep clone. | ||
* @returns {Object} Returns the initialized clone. | ||
*/ | ||
function initCloneByTag(object, tag, isDeep) { | ||
var Ctor = object.constructor; | ||
switch (tag) { | ||
case arrayBufferTag: | ||
return cloneArrayBuffer(object); | ||
case boolTag: | ||
case dateTag: | ||
return new Ctor(+object); | ||
case float32Tag: case float64Tag: | ||
case int8Tag: case int16Tag: case int32Tag: | ||
case uint8Tag: case uint8ClampedTag: case uint16Tag: case uint32Tag: | ||
return cloneTypedArray(object, isDeep); | ||
case mapTag: | ||
return cloneMap(object); | ||
case numberTag: | ||
case stringTag: | ||
return new Ctor(object); | ||
case regexpTag: | ||
return cloneRegExp(object); | ||
case setTag: | ||
return cloneSet(object); | ||
case symbolTag: | ||
return cloneSymbol(object); | ||
} | ||
} | ||
/** | ||
* Checks if the given arguments are from an iteratee call. | ||
@@ -917,16 +408,2 @@ * | ||
/** | ||
* Checks if `value` is likely a prototype object. | ||
* | ||
* @private | ||
* @param {*} value The value to check. | ||
* @returns {boolean} Returns `true` if `value` is a prototype, else `false`. | ||
*/ | ||
function isPrototype(value) { | ||
var Ctor = value && value.constructor, | ||
proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto; | ||
return value === proto; | ||
} | ||
/** | ||
* Performs a [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero) | ||
@@ -1177,29 +654,2 @@ * comparison between two values to determine if they are equivalent. | ||
/** | ||
* Checks if `value` is a native function. | ||
* | ||
* @static | ||
* @memberOf _ | ||
* @category Lang | ||
* @param {*} value The value to check. | ||
* @returns {boolean} Returns `true` if `value` is a native function, else `false`. | ||
* @example | ||
* | ||
* _.isNative(Array.prototype.push); | ||
* // => true | ||
* | ||
* _.isNative(_); | ||
* // => false | ||
*/ | ||
function isNative(value) { | ||
if (value == null) { | ||
return false; | ||
} | ||
if (isFunction(value)) { | ||
return reIsNative.test(funcToString.call(value)); | ||
} | ||
return isObjectLike(value) && | ||
(isHostObject(value) ? reIsNative : reIsHostCtor).test(value); | ||
} | ||
/** | ||
* Checks if `value` is classified as a typed array. | ||
@@ -1206,0 +656,0 @@ * |
{ | ||
"name": "lodash.mergewith", | ||
"version": "4.2.0", | ||
"version": "4.3.0", | ||
"description": "The lodash method `_.mergeWith` exported as a module.", | ||
@@ -18,8 +18,5 @@ "homepage": "https://lodash.com/", | ||
"dependencies": { | ||
"lodash._basefor": "^3.0.0", | ||
"lodash._root": "^3.0.0", | ||
"lodash._baseclone": "^4.0.0", | ||
"lodash._stack": "^4.0.0", | ||
"lodash.isbuffer": "^4.0.0", | ||
"lodash.isplainobject": "^4.0.0", | ||
"lodash.keys": "^4.0.0", | ||
"lodash.keysin": "^4.0.0", | ||
@@ -26,0 +23,0 @@ "lodash.rest": "^4.0.0" |
@@ -1,2 +0,2 @@ | ||
# lodash.mergewith v4.2.0 | ||
# lodash.mergewith v4.3.0 | ||
@@ -18,2 +18,2 @@ The [lodash](https://lodash.com/) method `_.mergeWith` exported as a [Node.js](https://nodejs.org/) module. | ||
See the [documentation](https://lodash.com/docs#mergeWith) or [package source](https://github.com/lodash/lodash/blob/4.2.0-npm-packages/lodash.mergewith) for more details. | ||
See the [documentation](https://lodash.com/docs#mergeWith) or [package source](https://github.com/lodash/lodash/blob/4.3.0-npm-packages/lodash.mergewith) for more details. |
5
22916
681
+ Addedlodash._baseclone@^4.0.0
+ Addedlodash._baseclone@4.5.7(transitive)
- Removedlodash._basefor@^3.0.0
- Removedlodash._root@^3.0.0
- Removedlodash.isbuffer@^4.0.0
- Removedlodash.keys@^4.0.0
- Removedlodash._basefor@3.0.3(transitive)
- Removedlodash._root@3.0.1(transitive)
- Removedlodash.isbuffer@4.3.4(transitive)
- Removedlodash.keys@4.2.0(transitive)