Add bitmask to baseClone.

This commit is contained in:
John-David Dalton
2016-11-07 21:57:25 -08:00
parent 2e4c997dba
commit 3d0df11e50

318
lodash.js
View File

@@ -30,21 +30,26 @@
/** Used as the internal argument placeholder. */ /** Used as the internal argument placeholder. */
var PLACEHOLDER = '__lodash_placeholder__'; var PLACEHOLDER = '__lodash_placeholder__';
/** Used to compose bitmasks for function metadata. */ /** Used to compose bitmasks for cloning. */
var BIND_FLAG = 1, var CLONE_DEEP_FLAG = 1,
BIND_KEY_FLAG = 2, CLONE_FLAT_FLAG = 2,
CURRY_BOUND_FLAG = 4, CLONE_SYMBOLS_FLAG = 4;
CURRY_FLAG = 8,
CURRY_RIGHT_FLAG = 16,
PARTIAL_FLAG = 32,
PARTIAL_RIGHT_FLAG = 64,
ARY_FLAG = 128,
REARG_FLAG = 256,
FLIP_FLAG = 512;
/** Used to compose bitmasks for comparison styles. */ /** Used to compose bitmasks for value comparisons. */
var UNORDERED_COMPARE_FLAG = 1, var COMPARE_PARTIAL_FLAG = 1,
PARTIAL_COMPARE_FLAG = 2; COMPARE_UNORDERED_FLAG = 2;
/** Used to compose bitmasks for function metadata. */
var WRAP_BIND_FLAG = 1,
WRAP_BIND_KEY_FLAG = 2,
WRAP_CURRY_BOUND_FLAG = 4,
WRAP_CURRY_FLAG = 8,
WRAP_CURRY_RIGHT_FLAG = 16,
WRAP_PARTIAL_FLAG = 32,
WRAP_PARTIAL_RIGHT_FLAG = 64,
WRAP_ARY_FLAG = 128,
WRAP_REARG_FLAG = 256,
WRAP_FLIP_FLAG = 512;
/** Used as default options for `_.truncate`. */ /** Used as default options for `_.truncate`. */
var DEFAULT_TRUNC_LENGTH = 30, var DEFAULT_TRUNC_LENGTH = 30,
@@ -72,15 +77,15 @@
/** Used to associate wrap methods with their bit flags. */ /** Used to associate wrap methods with their bit flags. */
var wrapFlags = [ var wrapFlags = [
['ary', ARY_FLAG], ['ary', WRAP_ARY_FLAG],
['bind', BIND_FLAG], ['bind', WRAP_BIND_FLAG],
['bindKey', BIND_KEY_FLAG], ['bindKey', WRAP_BIND_KEY_FLAG],
['curry', CURRY_FLAG], ['curry', WRAP_CURRY_FLAG],
['curryRight', CURRY_RIGHT_FLAG], ['curryRight', WRAP_CURRY_RIGHT_FLAG],
['flip', FLIP_FLAG], ['flip', WRAP_FLIP_FLAG],
['partial', PARTIAL_FLAG], ['partial', WRAP_PARTIAL_FLAG],
['partialRight', PARTIAL_RIGHT_FLAG], ['partialRight', WRAP_PARTIAL_RIGHT_FLAG],
['rearg', REARG_FLAG] ['rearg', WRAP_REARG_FLAG]
]; ];
/** `Object#toString` result references. */ /** `Object#toString` result references. */
@@ -2560,6 +2565,19 @@
return object && copyObject(source, keys(source), object); return object && copyObject(source, keys(source), object);
} }
/**
* The base implementation of `_.assignIn` 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 baseAssignIn(object, source) {
return object && copyObject(source, keysIn(source), object);
}
/** /**
* The base implementation of `assignValue` and `assignMergeValue` without * The base implementation of `assignValue` and `assignMergeValue` without
* value checks. * value checks.
@@ -2629,16 +2647,22 @@
* *
* @private * @private
* @param {*} value The value to clone. * @param {*} value The value to clone.
* @param {boolean} [isDeep] Specify a deep clone. * @param {boolean} bitmask The bitmask flags.
* @param {boolean} [isFull] Specify a clone including symbols. * 1 - Deep clone
* 2 - Clone symbols
* 4 - Flatten inherited properties
* @param {Function} [customizer] The function to customize cloning. * @param {Function} [customizer] The function to customize cloning.
* @param {string} [key] The key of `value`. * @param {string} [key] The key of `value`.
* @param {Object} [object] The parent object of `value`. * @param {Object} [object] The parent object of `value`.
* @param {Object} [stack] Tracks traversed objects and their clone counterparts. * @param {Object} [stack] Tracks traversed objects and their clone counterparts.
* @returns {*} Returns the cloned value. * @returns {*} Returns the cloned value.
*/ */
function baseClone(value, isDeep, isFull, customizer, key, object, stack) { function baseClone(value, bitmask, customizer, key, object, stack) {
var result; var result,
isDeep = bitmask & CLONE_DEEP_FLAG,
isFlat = bitmask & CLONE_FLAT_FLAG,
isFull = bitmask & CLONE_SYMBOLS_FLAG;
if (customizer) { if (customizer) {
result = object ? customizer(value, key, object, stack) : customizer(value); result = object ? customizer(value, key, object, stack) : customizer(value);
} }
@@ -2662,9 +2686,11 @@
return cloneBuffer(value, isDeep); return cloneBuffer(value, isDeep);
} }
if (tag == objectTag || tag == argsTag || (isFunc && !object)) { if (tag == objectTag || tag == argsTag || (isFunc && !object)) {
result = initCloneObject(isFunc ? {} : value); result = isFlat ? {} : initCloneObject(isFunc ? {} : value);
if (!isDeep) { if (!isDeep) {
return copySymbols(value, baseAssign(result, value)); return isFlat
? copySymbolsIn(value, baseAssignIn(result, value))
: copySymbols(value, baseAssign(result, value));
} }
} else { } else {
if (!cloneableTags[tag]) { if (!cloneableTags[tag]) {
@@ -2681,14 +2707,18 @@
} }
stack.set(value, result); stack.set(value, result);
var props = isArr ? undefined : (isFull ? getAllKeys : keys)(value); var keysFunc = isFull
? (isFlat ? getAllKeysIn : getAllKeys)
: (isFlat ? keysIn : keys);
var props = isArr ? undefined : keysFunc(value);
arrayEach(props || value, function(subValue, key) { arrayEach(props || value, function(subValue, key) {
if (props) { if (props) {
key = subValue; key = subValue;
subValue = value[key]; subValue = value[key];
} }
// Recursively populate clone (susceptible to call stack limits). // Recursively populate clone (susceptible to call stack limits).
assignValue(result, key, baseClone(subValue, isDeep, isFull, customizer, key, value, stack)); assignValue(result, key, baseClone(subValue, bitmask, customizer, key, value, stack));
}); });
return result; return result;
} }
@@ -3261,22 +3291,21 @@
* @private * @private
* @param {*} value The value to compare. * @param {*} value The value to compare.
* @param {*} other The other value to compare. * @param {*} other The other value to compare.
* @param {boolean} bitmask The bitmask flags.
* 1 - Unordered comparison
* 2 - Partial comparison
* @param {Function} [customizer] The function to customize comparisons. * @param {Function} [customizer] The function to customize comparisons.
* @param {boolean} [bitmask] The bitmask of comparison flags.
* The bitmask may be composed of the following flags:
* 1 - Unordered comparison
* 2 - Partial comparison
* @param {Object} [stack] Tracks traversed `value` and `other` objects. * @param {Object} [stack] Tracks traversed `value` and `other` objects.
* @returns {boolean} Returns `true` if the values are equivalent, else `false`. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
*/ */
function baseIsEqual(value, other, customizer, bitmask, stack) { function baseIsEqual(value, other, bitmask, customizer, stack) {
if (value === other) { if (value === other) {
return true; return true;
} }
if (value == null || other == null || (!isObject(value) && !isObjectLike(other))) { if (value == null || other == null || (!isObject(value) && !isObjectLike(other))) {
return value !== value && other !== other; return value !== value && other !== other;
} }
return baseIsEqualDeep(value, other, baseIsEqual, customizer, bitmask, stack); return baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual, stack);
} }
/** /**
@@ -3287,14 +3316,13 @@
* @private * @private
* @param {Object} object The object to compare. * @param {Object} object The object to compare.
* @param {Object} other The other object to compare. * @param {Object} other The other object to compare.
* @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
* @param {Function} customizer The function to customize comparisons.
* @param {Function} equalFunc The function to determine equivalents of values. * @param {Function} equalFunc The function to determine equivalents of values.
* @param {Function} [customizer] The function to customize comparisons.
* @param {number} [bitmask] The bitmask of comparison flags. See `baseIsEqual`
* for more details.
* @param {Object} [stack] Tracks traversed `object` and `other` objects. * @param {Object} [stack] Tracks traversed `object` and `other` objects.
* @returns {boolean} Returns `true` if the objects are equivalent, else `false`. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
*/ */
function baseIsEqualDeep(object, other, equalFunc, customizer, bitmask, stack) { function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) {
var objIsArr = isArray(object), var objIsArr = isArray(object),
othIsArr = isArray(other), othIsArr = isArray(other),
objTag = arrayTag, objTag = arrayTag,
@@ -3322,10 +3350,10 @@
if (isSameTag && !objIsObj) { if (isSameTag && !objIsObj) {
stack || (stack = new Stack); stack || (stack = new Stack);
return (objIsArr || isTypedArray(object)) return (objIsArr || isTypedArray(object))
? equalArrays(object, other, equalFunc, customizer, bitmask, stack) ? equalArrays(object, other, bitmask, customizer, equalFunc, stack)
: equalByTag(object, other, objTag, equalFunc, customizer, bitmask, stack); : equalByTag(object, other, objTag, bitmask, customizer, equalFunc, stack);
} }
if (!(bitmask & PARTIAL_COMPARE_FLAG)) { if (!(bitmask & COMPARE_PARTIAL_FLAG)) {
var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'), var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'),
othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__'); othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__');
@@ -3334,14 +3362,14 @@
othUnwrapped = othIsWrapped ? other.value() : other; othUnwrapped = othIsWrapped ? other.value() : other;
stack || (stack = new Stack); stack || (stack = new Stack);
return equalFunc(objUnwrapped, othUnwrapped, customizer, bitmask, stack); return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack);
} }
} }
if (!isSameTag) { if (!isSameTag) {
return false; return false;
} }
stack || (stack = new Stack); stack || (stack = new Stack);
return equalObjects(object, other, equalFunc, customizer, bitmask, stack); return equalObjects(object, other, bitmask, customizer, equalFunc, stack);
} }
/** /**
@@ -3399,7 +3427,7 @@
var result = customizer(objValue, srcValue, key, object, source, stack); var result = customizer(objValue, srcValue, key, object, source, stack);
} }
if (!(result === undefined if (!(result === undefined
? baseIsEqual(srcValue, objValue, customizer, UNORDERED_COMPARE_FLAG | PARTIAL_COMPARE_FLAG, stack) ? baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG, customizer, stack)
: result : result
)) { )) {
return false; return false;
@@ -3589,7 +3617,7 @@
var objValue = get(object, path); var objValue = get(object, path);
return (objValue === undefined && objValue === srcValue) return (objValue === undefined && objValue === srcValue)
? hasIn(object, path) ? hasIn(object, path)
: baseIsEqual(srcValue, objValue, undefined, UNORDERED_COMPARE_FLAG | PARTIAL_COMPARE_FLAG); : baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG);
}; };
} }
@@ -4324,7 +4352,7 @@
* *
* @private * @private
* @param {Object} object The object to modify. * @param {Object} object The object to modify.
* @param {Array|string} path The path of the property to unset. * @param {Array|string} path The property path to unset.
* @returns {boolean} Returns `true` if the property is deleted, else `false`. * @returns {boolean} Returns `true` if the property is deleted, else `false`.
*/ */
function baseUnset(object, path) { function baseUnset(object, path) {
@@ -4569,7 +4597,7 @@
* @returns {Object} Returns the cloned map. * @returns {Object} Returns the cloned map.
*/ */
function cloneMap(map, isDeep, cloneFunc) { function cloneMap(map, isDeep, cloneFunc) {
var array = isDeep ? cloneFunc(mapToArray(map), true) : mapToArray(map); var array = isDeep ? cloneFunc(mapToArray(map), CLONE_DEEP_FLAG) : mapToArray(map);
return arrayReduce(array, addMapEntry, new map.constructor); return arrayReduce(array, addMapEntry, new map.constructor);
} }
@@ -4596,7 +4624,7 @@
* @returns {Object} Returns the cloned set. * @returns {Object} Returns the cloned set.
*/ */
function cloneSet(set, isDeep, cloneFunc) { function cloneSet(set, isDeep, cloneFunc) {
var array = isDeep ? cloneFunc(setToArray(set), true) : setToArray(set); var array = isDeep ? cloneFunc(setToArray(set), CLONE_DEEP_FLAG) : setToArray(set);
return arrayReduce(array, addSetEntry, new set.constructor); return arrayReduce(array, addSetEntry, new set.constructor);
} }
@@ -4831,7 +4859,7 @@
} }
/** /**
* Copies own symbol properties of `source` to `object`. * Copies own symbols of `source` to `object`.
* *
* @private * @private
* @param {Object} source The object to copy symbols from. * @param {Object} source The object to copy symbols from.
@@ -4842,6 +4870,18 @@
return copyObject(source, getSymbols(source), object); return copyObject(source, getSymbols(source), object);
} }
/**
* Copies own and inherited symbols 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 copySymbolsIn(source, object) {
return copyObject(source, getSymbolsIn(source), object);
}
/** /**
* Creates a function like `_.groupBy`. * Creates a function like `_.groupBy`.
* *
@@ -4956,7 +4996,7 @@
* @returns {Function} Returns the new wrapped function. * @returns {Function} Returns the new wrapped function.
*/ */
function createBind(func, bitmask, thisArg) { function createBind(func, bitmask, thisArg) {
var isBind = bitmask & BIND_FLAG, var isBind = bitmask & WRAP_BIND_FLAG,
Ctor = createCtor(func); Ctor = createCtor(func);
function wrapper() { function wrapper() {
@@ -5129,7 +5169,7 @@
data = funcName == 'wrapper' ? getData(func) : undefined; data = funcName == 'wrapper' ? getData(func) : undefined;
if (data && isLaziable(data[0]) && if (data && isLaziable(data[0]) &&
data[1] == (ARY_FLAG | CURRY_FLAG | PARTIAL_FLAG | REARG_FLAG) && data[1] == (WRAP_ARY_FLAG | WRAP_CURRY_FLAG | WRAP_PARTIAL_FLAG | WRAP_REARG_FLAG) &&
!data[4].length && data[9] == 1 !data[4].length && data[9] == 1
) { ) {
wrapper = wrapper[getFuncName(data[0])].apply(wrapper, data[3]); wrapper = wrapper[getFuncName(data[0])].apply(wrapper, data[3]);
@@ -5178,11 +5218,11 @@
* @returns {Function} Returns the new wrapped function. * @returns {Function} Returns the new wrapped function.
*/ */
function createHybrid(func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, argPos, ary, arity) { function createHybrid(func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, argPos, ary, arity) {
var isAry = bitmask & ARY_FLAG, var isAry = bitmask & WRAP_ARY_FLAG,
isBind = bitmask & BIND_FLAG, isBind = bitmask & WRAP_BIND_FLAG,
isBindKey = bitmask & BIND_KEY_FLAG, isBindKey = bitmask & WRAP_BIND_KEY_FLAG,
isCurried = bitmask & (CURRY_FLAG | CURRY_RIGHT_FLAG), isCurried = bitmask & (WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG),
isFlip = bitmask & FLIP_FLAG, isFlip = bitmask & WRAP_FLIP_FLAG,
Ctor = isBindKey ? undefined : createCtor(func); Ctor = isBindKey ? undefined : createCtor(func);
function wrapper() { function wrapper() {
@@ -5333,7 +5373,7 @@
* @returns {Function} Returns the new wrapped function. * @returns {Function} Returns the new wrapped function.
*/ */
function createPartial(func, bitmask, thisArg, partials) { function createPartial(func, bitmask, thisArg, partials) {
var isBind = bitmask & BIND_FLAG, var isBind = bitmask & WRAP_BIND_FLAG,
Ctor = createCtor(func); Ctor = createCtor(func);
function wrapper() { function wrapper() {
@@ -5415,17 +5455,17 @@
* @returns {Function} Returns the new wrapped function. * @returns {Function} Returns the new wrapped function.
*/ */
function createRecurry(func, bitmask, wrapFunc, placeholder, thisArg, partials, holders, argPos, ary, arity) { function createRecurry(func, bitmask, wrapFunc, placeholder, thisArg, partials, holders, argPos, ary, arity) {
var isCurry = bitmask & CURRY_FLAG, var isCurry = bitmask & WRAP_CURRY_FLAG,
newHolders = isCurry ? holders : undefined, newHolders = isCurry ? holders : undefined,
newHoldersRight = isCurry ? undefined : holders, newHoldersRight = isCurry ? undefined : holders,
newPartials = isCurry ? partials : undefined, newPartials = isCurry ? partials : undefined,
newPartialsRight = isCurry ? undefined : partials; newPartialsRight = isCurry ? undefined : partials;
bitmask |= (isCurry ? PARTIAL_FLAG : PARTIAL_RIGHT_FLAG); bitmask |= (isCurry ? WRAP_PARTIAL_FLAG : WRAP_PARTIAL_RIGHT_FLAG);
bitmask &= ~(isCurry ? PARTIAL_RIGHT_FLAG : PARTIAL_FLAG); bitmask &= ~(isCurry ? WRAP_PARTIAL_RIGHT_FLAG : WRAP_PARTIAL_FLAG);
if (!(bitmask & CURRY_BOUND_FLAG)) { if (!(bitmask & WRAP_CURRY_BOUND_FLAG)) {
bitmask &= ~(BIND_FLAG | BIND_KEY_FLAG); bitmask &= ~(WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG);
} }
var newData = [ var newData = [
func, bitmask, thisArg, newPartials, newHolders, newPartialsRight, func, bitmask, thisArg, newPartials, newHolders, newPartialsRight,
@@ -5503,17 +5543,16 @@
* @private * @private
* @param {Function|string} func The function or method name to wrap. * @param {Function|string} func The function or method name to wrap.
* @param {number} bitmask The bitmask flags. * @param {number} bitmask The bitmask flags.
* The bitmask may be composed of the following flags: * 1 - `_.bind`
* 1 - `_.bind` * 2 - `_.bindKey`
* 2 - `_.bindKey` * 4 - `_.curry` or `_.curryRight` of a bound function
* 4 - `_.curry` or `_.curryRight` of a bound function * 8 - `_.curry`
* 8 - `_.curry` * 16 - `_.curryRight`
* 16 - `_.curryRight` * 32 - `_.partial`
* 32 - `_.partial` * 64 - `_.partialRight`
* 64 - `_.partialRight` * 128 - `_.rearg`
* 128 - `_.rearg` * 256 - `_.ary`
* 256 - `_.ary` * 512 - `_.flip`
* 512 - `_.flip`
* @param {*} [thisArg] The `this` binding of `func`. * @param {*} [thisArg] The `this` binding of `func`.
* @param {Array} [partials] The arguments to be partially applied. * @param {Array} [partials] The arguments to be partially applied.
* @param {Array} [holders] The `partials` placeholder indexes. * @param {Array} [holders] The `partials` placeholder indexes.
@@ -5523,20 +5562,20 @@
* @returns {Function} Returns the new wrapped function. * @returns {Function} Returns the new wrapped function.
*/ */
function createWrap(func, bitmask, thisArg, partials, holders, argPos, ary, arity) { function createWrap(func, bitmask, thisArg, partials, holders, argPos, ary, arity) {
var isBindKey = bitmask & BIND_KEY_FLAG; var isBindKey = bitmask & WRAP_BIND_KEY_FLAG;
if (!isBindKey && typeof func != 'function') { if (!isBindKey && typeof func != 'function') {
throw new TypeError(FUNC_ERROR_TEXT); throw new TypeError(FUNC_ERROR_TEXT);
} }
var length = partials ? partials.length : 0; var length = partials ? partials.length : 0;
if (!length) { if (!length) {
bitmask &= ~(PARTIAL_FLAG | PARTIAL_RIGHT_FLAG); bitmask &= ~(WRAP_PARTIAL_FLAG | WRAP_PARTIAL_RIGHT_FLAG);
partials = holders = undefined; partials = holders = undefined;
} }
ary = ary === undefined ? ary : nativeMax(toInteger(ary), 0); ary = ary === undefined ? ary : nativeMax(toInteger(ary), 0);
arity = arity === undefined ? arity : toInteger(arity); arity = arity === undefined ? arity : toInteger(arity);
length -= holders ? holders.length : 0; length -= holders ? holders.length : 0;
if (bitmask & PARTIAL_RIGHT_FLAG) { if (bitmask & WRAP_PARTIAL_RIGHT_FLAG) {
var partialsRight = partials, var partialsRight = partials,
holdersRight = holders; holdersRight = holders;
@@ -5561,14 +5600,14 @@
? (isBindKey ? 0 : func.length) ? (isBindKey ? 0 : func.length)
: nativeMax(newData[9] - length, 0); : nativeMax(newData[9] - length, 0);
if (!arity && bitmask & (CURRY_FLAG | CURRY_RIGHT_FLAG)) { if (!arity && bitmask & (WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG)) {
bitmask &= ~(CURRY_FLAG | CURRY_RIGHT_FLAG); bitmask &= ~(WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG);
} }
if (!bitmask || bitmask == BIND_FLAG) { if (!bitmask || bitmask == WRAP_BIND_FLAG) {
var result = createBind(func, bitmask, thisArg); var result = createBind(func, bitmask, thisArg);
} else if (bitmask == CURRY_FLAG || bitmask == CURRY_RIGHT_FLAG) { } else if (bitmask == WRAP_CURRY_FLAG || bitmask == WRAP_CURRY_RIGHT_FLAG) {
result = createCurry(func, bitmask, arity); result = createCurry(func, bitmask, arity);
} else if ((bitmask == PARTIAL_FLAG || bitmask == (BIND_FLAG | PARTIAL_FLAG)) && !holders.length) { } else if ((bitmask == WRAP_PARTIAL_FLAG || bitmask == (WRAP_BIND_FLAG | WRAP_PARTIAL_FLAG)) && !holders.length) {
result = createPartial(func, bitmask, thisArg, partials); result = createPartial(func, bitmask, thisArg, partials);
} else { } else {
result = createHybrid.apply(undefined, newData); result = createHybrid.apply(undefined, newData);
@@ -5584,15 +5623,14 @@
* @private * @private
* @param {Array} array The array to compare. * @param {Array} array The array to compare.
* @param {Array} other The other array to compare. * @param {Array} other The other array to compare.
* @param {Function} equalFunc The function to determine equivalents of values. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
* @param {Function} customizer The function to customize comparisons. * @param {Function} customizer The function to customize comparisons.
* @param {number} bitmask The bitmask of comparison flags. See `baseIsEqual` * @param {Function} equalFunc The function to determine equivalents of values.
* for more details.
* @param {Object} stack Tracks traversed `array` and `other` objects. * @param {Object} stack Tracks traversed `array` and `other` objects.
* @returns {boolean} Returns `true` if the arrays are equivalent, else `false`. * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`.
*/ */
function equalArrays(array, other, equalFunc, customizer, bitmask, stack) { function equalArrays(array, other, bitmask, customizer, equalFunc, stack) {
var isPartial = bitmask & PARTIAL_COMPARE_FLAG, var isPartial = bitmask & COMPARE_PARTIAL_FLAG,
arrLength = array.length, arrLength = array.length,
othLength = other.length; othLength = other.length;
@@ -5606,7 +5644,7 @@
} }
var index = -1, var index = -1,
result = true, result = true,
seen = (bitmask & UNORDERED_COMPARE_FLAG) ? new SetCache : undefined; seen = (bitmask & COMPARE_UNORDERED_FLAG) ? new SetCache : undefined;
stack.set(array, other); stack.set(array, other);
stack.set(other, array); stack.set(other, array);
@@ -5632,7 +5670,7 @@
if (seen) { if (seen) {
if (!arraySome(other, function(othValue, othIndex) { if (!arraySome(other, function(othValue, othIndex) {
if (!cacheHas(seen, othIndex) && if (!cacheHas(seen, othIndex) &&
(arrValue === othValue || equalFunc(arrValue, othValue, customizer, bitmask, stack))) { (arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) {
return seen.push(othIndex); return seen.push(othIndex);
} }
})) { })) {
@@ -5641,7 +5679,7 @@
} }
} else if (!( } else if (!(
arrValue === othValue || arrValue === othValue ||
equalFunc(arrValue, othValue, customizer, bitmask, stack) equalFunc(arrValue, othValue, bitmask, customizer, stack)
)) { )) {
result = false; result = false;
break; break;
@@ -5663,14 +5701,13 @@
* @param {Object} object The object to compare. * @param {Object} object The object to compare.
* @param {Object} other The other object to compare. * @param {Object} other The other object to compare.
* @param {string} tag The `toStringTag` of the objects to compare. * @param {string} tag The `toStringTag` of the objects to compare.
* @param {Function} equalFunc The function to determine equivalents of values. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
* @param {Function} customizer The function to customize comparisons. * @param {Function} customizer The function to customize comparisons.
* @param {number} bitmask The bitmask of comparison flags. See `baseIsEqual` * @param {Function} equalFunc The function to determine equivalents of values.
* for more details.
* @param {Object} stack Tracks traversed `object` and `other` objects. * @param {Object} stack Tracks traversed `object` and `other` objects.
* @returns {boolean} Returns `true` if the objects are equivalent, else `false`. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
*/ */
function equalByTag(object, other, tag, equalFunc, customizer, bitmask, stack) { function equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) {
switch (tag) { switch (tag) {
case dataViewTag: case dataViewTag:
if ((object.byteLength != other.byteLength) || if ((object.byteLength != other.byteLength) ||
@@ -5708,7 +5745,7 @@
var convert = mapToArray; var convert = mapToArray;
case setTag: case setTag:
var isPartial = bitmask & PARTIAL_COMPARE_FLAG; var isPartial = bitmask & COMPARE_PARTIAL_FLAG;
convert || (convert = setToArray); convert || (convert = setToArray);
if (object.size != other.size && !isPartial) { if (object.size != other.size && !isPartial) {
@@ -5719,11 +5756,11 @@
if (stacked) { if (stacked) {
return stacked == other; return stacked == other;
} }
bitmask |= UNORDERED_COMPARE_FLAG; bitmask |= COMPARE_UNORDERED_FLAG;
// Recursively compare objects (susceptible to call stack limits). // Recursively compare objects (susceptible to call stack limits).
stack.set(object, other); stack.set(object, other);
var result = equalArrays(convert(object), convert(other), equalFunc, customizer, bitmask, stack); var result = equalArrays(convert(object), convert(other), bitmask, customizer, equalFunc, stack);
stack['delete'](object); stack['delete'](object);
return result; return result;
@@ -5742,15 +5779,14 @@
* @private * @private
* @param {Object} object The object to compare. * @param {Object} object The object to compare.
* @param {Object} other The other object to compare. * @param {Object} other The other object to compare.
* @param {Function} equalFunc The function to determine equivalents of values. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
* @param {Function} customizer The function to customize comparisons. * @param {Function} customizer The function to customize comparisons.
* @param {number} bitmask The bitmask of comparison flags. See `baseIsEqual` * @param {Function} equalFunc The function to determine equivalents of values.
* for more details.
* @param {Object} stack Tracks traversed `object` and `other` objects. * @param {Object} stack Tracks traversed `object` and `other` objects.
* @returns {boolean} Returns `true` if the objects are equivalent, else `false`. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
*/ */
function equalObjects(object, other, equalFunc, customizer, bitmask, stack) { function equalObjects(object, other, bitmask, customizer, equalFunc, stack) {
var isPartial = bitmask & PARTIAL_COMPARE_FLAG, var isPartial = bitmask & COMPARE_PARTIAL_FLAG,
objProps = keys(object), objProps = keys(object),
objLength = objProps.length, objLength = objProps.length,
othProps = keys(other), othProps = keys(other),
@@ -5788,7 +5824,7 @@
} }
// Recursively compare objects (susceptible to call stack limits). // Recursively compare objects (susceptible to call stack limits).
if (!(compared === undefined if (!(compared === undefined
? (objValue === othValue || equalFunc(objValue, othValue, customizer, bitmask, stack)) ? (objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack))
: compared : compared
)) { )) {
result = false; result = false;
@@ -5985,7 +6021,7 @@
} }
/** /**
* Creates an array of the own enumerable symbol properties of `object`. * Creates an array of the own enumerable symbols of `object`.
* *
* @private * @private
* @param {Object} object The object to query. * @param {Object} object The object to query.
@@ -5994,8 +6030,7 @@
var getSymbols = nativeGetSymbols ? overArg(nativeGetSymbols, Object) : stubArray; var getSymbols = nativeGetSymbols ? overArg(nativeGetSymbols, Object) : stubArray;
/** /**
* Creates an array of the own and inherited enumerable symbol properties * Creates an array of the own and inherited enumerable symbols of `object`.
* of `object`.
* *
* @private * @private
* @param {Object} object The object to query. * @param {Object} object The object to query.
@@ -6427,22 +6462,22 @@
var bitmask = data[1], var bitmask = data[1],
srcBitmask = source[1], srcBitmask = source[1],
newBitmask = bitmask | srcBitmask, newBitmask = bitmask | srcBitmask,
isCommon = newBitmask < (BIND_FLAG | BIND_KEY_FLAG | ARY_FLAG); isCommon = newBitmask < (WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG | WRAP_ARY_FLAG);
var isCombo = var isCombo =
((srcBitmask == ARY_FLAG) && (bitmask == CURRY_FLAG)) || ((srcBitmask == WRAP_ARY_FLAG) && (bitmask == WRAP_CURRY_FLAG)) ||
((srcBitmask == ARY_FLAG) && (bitmask == REARG_FLAG) && (data[7].length <= source[8])) || ((srcBitmask == WRAP_ARY_FLAG) && (bitmask == WRAP_REARG_FLAG) && (data[7].length <= source[8])) ||
((srcBitmask == (ARY_FLAG | REARG_FLAG)) && (source[7].length <= source[8]) && (bitmask == CURRY_FLAG)); ((srcBitmask == (WRAP_ARY_FLAG | WRAP_REARG_FLAG)) && (source[7].length <= source[8]) && (bitmask == WRAP_CURRY_FLAG));
// Exit early if metadata can't be merged. // Exit early if metadata can't be merged.
if (!(isCommon || isCombo)) { if (!(isCommon || isCombo)) {
return data; return data;
} }
// Use source `thisArg` if available. // Use source `thisArg` if available.
if (srcBitmask & BIND_FLAG) { if (srcBitmask & WRAP_BIND_FLAG) {
data[2] = source[2]; data[2] = source[2];
// Set when currying a bound function. // Set when currying a bound function.
newBitmask |= bitmask & BIND_FLAG ? 0 : CURRY_BOUND_FLAG; newBitmask |= bitmask & WRAP_BIND_FLAG ? 0 : WRAP_CURRY_BOUND_FLAG;
} }
// Compose partial arguments. // Compose partial arguments.
var value = source[3]; var value = source[3];
@@ -6464,7 +6499,7 @@
data[7] = value; data[7] = value;
} }
// Use source `ary` if it's smaller. // Use source `ary` if it's smaller.
if (srcBitmask & ARY_FLAG) { if (srcBitmask & WRAP_ARY_FLAG) {
data[8] = data[8] == null ? source[8] : nativeMin(data[8], source[8]); data[8] = data[8] == null ? source[8] : nativeMin(data[8], source[8]);
} }
// Use source `arity` if one is not provided. // Use source `arity` if one is not provided.
@@ -10000,7 +10035,7 @@
function ary(func, n, guard) { function ary(func, n, guard) {
n = guard ? undefined : n; n = guard ? undefined : n;
n = (func && n == null) ? func.length : n; n = (func && n == null) ? func.length : n;
return createWrap(func, ARY_FLAG, undefined, undefined, undefined, undefined, n); return createWrap(func, WRAP_ARY_FLAG, undefined, undefined, undefined, undefined, n);
} }
/** /**
@@ -10073,10 +10108,10 @@
* // => 'hi fred!' * // => 'hi fred!'
*/ */
var bind = baseRest(function(func, thisArg, partials) { var bind = baseRest(function(func, thisArg, partials) {
var bitmask = BIND_FLAG; var bitmask = WRAP_BIND_FLAG;
if (partials.length) { if (partials.length) {
var holders = replaceHolders(partials, getHolder(bind)); var holders = replaceHolders(partials, getHolder(bind));
bitmask |= PARTIAL_FLAG; bitmask |= WRAP_PARTIAL_FLAG;
} }
return createWrap(func, bitmask, thisArg, partials, holders); return createWrap(func, bitmask, thisArg, partials, holders);
}); });
@@ -10127,10 +10162,10 @@
* // => 'hiya fred!' * // => 'hiya fred!'
*/ */
var bindKey = baseRest(function(object, key, partials) { var bindKey = baseRest(function(object, key, partials) {
var bitmask = BIND_FLAG | BIND_KEY_FLAG; var bitmask = WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG;
if (partials.length) { if (partials.length) {
var holders = replaceHolders(partials, getHolder(bindKey)); var holders = replaceHolders(partials, getHolder(bindKey));
bitmask |= PARTIAL_FLAG; bitmask |= WRAP_PARTIAL_FLAG;
} }
return createWrap(key, bitmask, object, partials, holders); return createWrap(key, bitmask, object, partials, holders);
}); });
@@ -10178,7 +10213,7 @@
*/ */
function curry(func, arity, guard) { function curry(func, arity, guard) {
arity = guard ? undefined : arity; arity = guard ? undefined : arity;
var result = createWrap(func, CURRY_FLAG, undefined, undefined, undefined, undefined, undefined, arity); var result = createWrap(func, WRAP_CURRY_FLAG, undefined, undefined, undefined, undefined, undefined, arity);
result.placeholder = curry.placeholder; result.placeholder = curry.placeholder;
return result; return result;
} }
@@ -10223,7 +10258,7 @@
*/ */
function curryRight(func, arity, guard) { function curryRight(func, arity, guard) {
arity = guard ? undefined : arity; arity = guard ? undefined : arity;
var result = createWrap(func, CURRY_RIGHT_FLAG, undefined, undefined, undefined, undefined, undefined, arity); var result = createWrap(func, WRAP_CURRY_RIGHT_FLAG, undefined, undefined, undefined, undefined, undefined, arity);
result.placeholder = curryRight.placeholder; result.placeholder = curryRight.placeholder;
return result; return result;
} }
@@ -10468,7 +10503,7 @@
* // => ['d', 'c', 'b', 'a'] * // => ['d', 'c', 'b', 'a']
*/ */
function flip(func) { function flip(func) {
return createWrap(func, FLIP_FLAG); return createWrap(func, WRAP_FLIP_FLAG);
} }
/** /**
@@ -10679,7 +10714,7 @@
*/ */
var partial = baseRest(function(func, partials) { var partial = baseRest(function(func, partials) {
var holders = replaceHolders(partials, getHolder(partial)); var holders = replaceHolders(partials, getHolder(partial));
return createWrap(func, PARTIAL_FLAG, undefined, partials, holders); return createWrap(func, WRAP_PARTIAL_FLAG, undefined, partials, holders);
}); });
/** /**
@@ -10716,7 +10751,7 @@
*/ */
var partialRight = baseRest(function(func, partials) { var partialRight = baseRest(function(func, partials) {
var holders = replaceHolders(partials, getHolder(partialRight)); var holders = replaceHolders(partials, getHolder(partialRight));
return createWrap(func, PARTIAL_RIGHT_FLAG, undefined, partials, holders); return createWrap(func, WRAP_PARTIAL_RIGHT_FLAG, undefined, partials, holders);
}); });
/** /**
@@ -10742,7 +10777,7 @@
* // => ['a', 'b', 'c'] * // => ['a', 'b', 'c']
*/ */
var rearg = flatRest(function(func, indexes) { var rearg = flatRest(function(func, indexes) {
return createWrap(func, REARG_FLAG, undefined, undefined, undefined, indexes); return createWrap(func, WRAP_REARG_FLAG, undefined, undefined, undefined, indexes);
}); });
/** /**
@@ -11009,7 +11044,7 @@
* // => true * // => true
*/ */
function clone(value) { function clone(value) {
return baseClone(value, false, true); return baseClone(value, CLONE_SYMBOLS_FLAG);
} }
/** /**
@@ -11045,7 +11080,7 @@
*/ */
function cloneWith(value, customizer) { function cloneWith(value, customizer) {
customizer = typeof customizer == 'function' ? customizer : undefined; customizer = typeof customizer == 'function' ? customizer : undefined;
return baseClone(value, false, true, customizer); return baseClone(value, CLONE_SYMBOLS_FLAG, customizer);
} }
/** /**
@@ -11067,7 +11102,7 @@
* // => false * // => false
*/ */
function cloneDeep(value) { function cloneDeep(value) {
return baseClone(value, true, true); return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG);
} }
/** /**
@@ -11100,7 +11135,7 @@
*/ */
function cloneDeepWith(value, customizer) { function cloneDeepWith(value, customizer) {
customizer = typeof customizer == 'function' ? customizer : undefined; customizer = typeof customizer == 'function' ? customizer : undefined;
return baseClone(value, true, true, customizer); return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG, customizer);
} }
/** /**
@@ -11549,7 +11584,7 @@
function isEqualWith(value, other, customizer) { function isEqualWith(value, other, customizer) {
customizer = typeof customizer == 'function' ? customizer : undefined; customizer = typeof customizer == 'function' ? customizer : undefined;
var result = customizer ? customizer(value, other) : undefined; var result = customizer ? customizer(value, other) : undefined;
return result === undefined ? baseIsEqual(value, other, customizer) : !!result; return result === undefined ? baseIsEqual(value, other, undefined, customizer) : !!result;
} }
/** /**
@@ -13421,6 +13456,8 @@
* The opposite of `_.pick`; this method creates an object composed of the * The opposite of `_.pick`; this method creates an object composed of the
* own and inherited enumerable property paths of `object` that are not omitted. * own and inherited enumerable property paths of `object` that are not omitted.
* *
* **Note:** This method is considerably slower than `_.pick`.
*
* @static * @static
* @since 0.1.0 * @since 0.1.0
* @memberOf _ * @memberOf _
@@ -13439,8 +13476,13 @@
if (object == null) { if (object == null) {
return {}; return {};
} }
paths = arrayMap(paths, toKey); var length = paths.length,
return basePick(object, baseDifference(getAllKeysIn(object), paths)); result = baseClone(copyObject(object, getAllKeysIn(object), {}), CLONE_DEEP_FLAG | CLONE_FLAT_FLAG | CLONE_SYMBOLS_FLAG);
while (length--) {
baseUnset(result, paths[length]);
}
return result;
}); });
/** /**
@@ -15278,7 +15320,7 @@
* // => [{ 'a': 1, 'b': 2 }] * // => [{ 'a': 1, 'b': 2 }]
*/ */
function conforms(source) { function conforms(source) {
return baseConforms(baseClone(source, true)); return baseConforms(baseClone(source, CLONE_DEEP_FLAG));
} }
/** /**
@@ -15440,7 +15482,7 @@
* // => ['def'] * // => ['def']
*/ */
function iteratee(func) { function iteratee(func) {
return baseIteratee(typeof func == 'function' ? func : baseClone(func, true)); return baseIteratee(typeof func == 'function' ? func : baseClone(func, CLONE_DEEP_FLAG));
} }
/** /**
@@ -15472,7 +15514,7 @@
* // => [{ 'a': 4, 'b': 5, 'c': 6 }] * // => [{ 'a': 4, 'b': 5, 'c': 6 }]
*/ */
function matches(source) { function matches(source) {
return baseMatches(baseClone(source, true)); return baseMatches(baseClone(source, CLONE_DEEP_FLAG));
} }
/** /**
@@ -15502,7 +15544,7 @@
* // => { 'a': 4, 'b': 5, 'c': 6 } * // => { 'a': 4, 'b': 5, 'c': 6 }
*/ */
function matchesProperty(path, srcValue) { function matchesProperty(path, srcValue) {
return baseMatchesProperty(path, baseClone(srcValue, true)); return baseMatchesProperty(path, baseClone(srcValue, CLONE_DEEP_FLAG));
} }
/** /**
@@ -16962,7 +17004,7 @@
} }
}); });
realNames[createHybrid(undefined, BIND_KEY_FLAG).name] = [{ realNames[createHybrid(undefined, WRAP_BIND_KEY_FLAG).name] = [{
'name': 'wrapper', 'name': 'wrapper',
'func': undefined 'func': undefined
}]; }];