Compare commits

...

2 Commits

Author SHA1 Message Date
John-David Dalton
7da4c55415 Bump to v4.6.0. 2016-02-29 23:41:02 -08:00
John-David Dalton
9055c4e483 Bump to v4.5.1. 2016-02-21 20:49:38 -08:00
86 changed files with 545 additions and 315 deletions

View File

@@ -1,4 +1,4 @@
# lodash-es v4.5.0 # lodash-es v4.6.0
The [lodash](https://lodash.com/) library exported as [ES](http://www.ecma-international.org/ecma-262/6.0/) modules. The [lodash](https://lodash.com/) library exported as [ES](http://www.ecma-international.org/ecma-262/6.0/) modules.
@@ -7,4 +7,4 @@ Generated using [lodash-cli](https://www.npmjs.com/package/lodash-cli):
$ lodash modularize exports=es -o ./ $ lodash modularize exports=es -o ./
``` ```
See the [package source](https://github.com/lodash/lodash/tree/4.5.0-es) for more details. See the [package source](https://github.com/lodash/lodash/tree/4.6.0-es) for more details.

View File

@@ -7,6 +7,7 @@
* @returns {Object} Returns `map`. * @returns {Object} Returns `map`.
*/ */
function addMapEntry(map, pair) { function addMapEntry(map, pair) {
// Don't return `Map#set` because it doesn't return the map instance in IE 11.
map.set(pair[0], pair[1]); map.set(pair[0], pair[1]);
return map; return map;
} }

View File

@@ -10,13 +10,13 @@
function arrayFilter(array, predicate) { function arrayFilter(array, predicate) {
var index = -1, var index = -1,
length = array.length, length = array.length,
resIndex = -1, resIndex = 0,
result = []; result = [];
while (++index < length) { while (++index < length) {
var value = array[index]; var value = array[index];
if (predicate(value, index, array)) { if (predicate(value, index, array)) {
result[++resIndex] = value; result[resIndex++] = value;
} }
} }
return result; return result;

View File

@@ -1,6 +1,5 @@
/** /**
* A specialized version of `_.includesWith` for arrays without support for * This function is like `arrayIncludes` except that it accepts a comparator.
* specifying an index to search from.
* *
* @private * @private
* @param {Array} array The array to search. * @param {Array} array The array to search.

View File

@@ -1,7 +1,8 @@
import eq from './eq'; import eq from './eq';
/** /**
* This function is like `assignValue` except that it doesn't assign `undefined` values. * This function is like `assignValue` except that it doesn't assign
* `undefined` values.
* *
* @private * @private
* @param {Object} object The object to modify. * @param {Object} object The object to modify.

View File

@@ -18,8 +18,7 @@ var hasOwnProperty = objectProto.hasOwnProperty;
*/ */
function assignValue(object, key, value) { function assignValue(object, key, value) {
var objValue = object[key]; var objValue = object[key];
if ((!eq(objValue, value) || if (!(hasOwnProperty.call(object, key) && eq(objValue, value)) ||
(eq(objValue, objectProto[key]) && !hasOwnProperty.call(object, key))) ||
(value === undefined && !(key in object))) { (value === undefined && !(key in object))) {
object[key] = value; object[key] = value;
} }

23
_baseIndexOfWith.js Normal file
View File

@@ -0,0 +1,23 @@
/**
* This function is like `baseIndexOf` except that it accepts a comparator.
*
* @private
* @param {Array} array The array to search.
* @param {*} value The value to search for.
* @param {number} fromIndex The index to search from.
* @param {Function} comparator The comparator invoked per element.
* @returns {number} Returns the index of the matched value, else `-1`.
*/
function baseIndexOfWith(array, value, fromIndex, comparator) {
var index = fromIndex - 1,
length = array.length;
while (++index < length) {
if (comparator(array[index], value)) {
return index;
}
}
return -1;
}
export default baseIndexOfWith;

View File

@@ -5,6 +5,9 @@ import arrayMap from './_arrayMap';
import baseUnary from './_baseUnary'; import baseUnary from './_baseUnary';
import cacheHas from './_cacheHas'; import cacheHas from './_cacheHas';
/* Built-in method references for those with the same name as other `lodash` methods. */
var nativeMin = Math.min;
/** /**
* The base implementation of methods like `_.intersection`, without support * The base implementation of methods like `_.intersection`, without support
* for iteratee shorthands, that accepts an array of arrays to inspect. * for iteratee shorthands, that accepts an array of arrays to inspect.
@@ -17,9 +20,11 @@ import cacheHas from './_cacheHas';
*/ */
function baseIntersection(arrays, iteratee, comparator) { function baseIntersection(arrays, iteratee, comparator) {
var includes = comparator ? arrayIncludesWith : arrayIncludes, var includes = comparator ? arrayIncludesWith : arrayIncludes,
length = arrays[0].length,
othLength = arrays.length, othLength = arrays.length,
othIndex = othLength, othIndex = othLength,
caches = Array(othLength), caches = Array(othLength),
maxLength = Infinity,
result = []; result = [];
while (othIndex--) { while (othIndex--) {
@@ -27,18 +32,18 @@ function baseIntersection(arrays, iteratee, comparator) {
if (othIndex && iteratee) { if (othIndex && iteratee) {
array = arrayMap(array, baseUnary(iteratee)); array = arrayMap(array, baseUnary(iteratee));
} }
caches[othIndex] = !comparator && (iteratee || array.length >= 120) maxLength = nativeMin(array.length, maxLength);
caches[othIndex] = !comparator && (iteratee || (length >= 120 && array.length >= 120))
? new SetCache(othIndex && array) ? new SetCache(othIndex && array)
: undefined; : undefined;
} }
array = arrays[0]; array = arrays[0];
var index = -1, var index = -1,
length = array.length,
seen = caches[0]; seen = caches[0];
outer: outer:
while (++index < length) { while (++index < length && result.length < maxLength) {
var value = array[index], var value = array[index],
computed = iteratee ? iteratee(value) : value; computed = iteratee ? iteratee(value) : value;
@@ -46,7 +51,7 @@ function baseIntersection(arrays, iteratee, comparator) {
? cacheHas(seen, computed) ? cacheHas(seen, computed)
: includes(result, computed, comparator) : includes(result, computed, comparator)
)) { )) {
var othIndex = othLength; othIndex = othLength;
while (--othIndex) { while (--othIndex) {
var cache = caches[othIndex]; var cache = caches[othIndex];
if (!(cache if (!(cache

View File

@@ -43,33 +43,28 @@ function baseIsEqualDeep(object, other, equalFunc, customizer, bitmask, stack) {
if (!objIsArr) { if (!objIsArr) {
objTag = getTag(object); objTag = getTag(object);
if (objTag == argsTag) { objTag = objTag == argsTag ? objectTag : objTag;
objTag = objectTag;
} else if (objTag != objectTag) {
objIsArr = isTypedArray(object);
}
} }
if (!othIsArr) { if (!othIsArr) {
othTag = getTag(other); othTag = getTag(other);
if (othTag == argsTag) { othTag = othTag == argsTag ? objectTag : othTag;
othTag = objectTag;
} else if (othTag != objectTag) {
othIsArr = isTypedArray(other);
}
} }
var objIsObj = objTag == objectTag && !isHostObject(object), var objIsObj = objTag == objectTag && !isHostObject(object),
othIsObj = othTag == objectTag && !isHostObject(other), othIsObj = othTag == objectTag && !isHostObject(other),
isSameTag = objTag == othTag; isSameTag = objTag == othTag;
if (isSameTag && !(objIsArr || objIsObj)) { if (isSameTag && !objIsObj) {
return equalByTag(object, other, objTag, equalFunc, customizer, bitmask); stack || (stack = new Stack);
return (objIsArr || isTypedArray(object))
? equalArrays(object, other, equalFunc, customizer, bitmask, stack)
: equalByTag(object, other, objTag, equalFunc, customizer, bitmask, stack);
} }
var isPartial = bitmask & PARTIAL_COMPARE_FLAG; if (!(bitmask & PARTIAL_COMPARE_FLAG)) {
if (!isPartial) {
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__');
if (objIsWrapped || othIsWrapped) { if (objIsWrapped || othIsWrapped) {
stack || (stack = new Stack);
return equalFunc(objIsWrapped ? object.value() : object, othIsWrapped ? other.value() : other, customizer, bitmask, stack); return equalFunc(objIsWrapped ? object.value() : object, othIsWrapped ? other.value() : other, customizer, bitmask, stack);
} }
} }
@@ -77,7 +72,7 @@ function baseIsEqualDeep(object, other, equalFunc, customizer, bitmask, stack) {
return false; return false;
} }
stack || (stack = new Stack); stack || (stack = new Stack);
return (objIsArr ? equalArrays : equalObjects)(object, other, equalFunc, customizer, bitmask, stack); return equalObjects(object, other, equalFunc, customizer, bitmask, stack);
} }
export default baseIsEqualDeep; export default baseIsEqualDeep;

View File

@@ -50,7 +50,7 @@ function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, sta
} }
else { else {
isCommon = false; isCommon = false;
newValue = baseClone(srcValue, true); newValue = baseClone(srcValue, !customizer);
} }
} }
else if (isPlainObject(srcValue) || isArguments(srcValue)) { else if (isPlainObject(srcValue) || isArguments(srcValue)) {
@@ -59,7 +59,7 @@ function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, sta
} }
else if (!isObject(objValue) || (srcIndex && isFunction(objValue))) { else if (!isObject(objValue) || (srcIndex && isFunction(objValue))) {
isCommon = false; isCommon = false;
newValue = baseClone(srcValue, true); newValue = baseClone(srcValue, !customizer);
} }
else { else {
newValue = objValue; newValue = objValue;
@@ -75,6 +75,7 @@ function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, sta
// Recursively merge objects and arrays (susceptible to call stack limits). // Recursively merge objects and arrays (susceptible to call stack limits).
mergeFunc(newValue, srcValue, srcIndex, customizer, stack); mergeFunc(newValue, srcValue, srcIndex, customizer, stack);
} }
stack['delete'](srcValue);
assignMergeValue(object, key, newValue); assignMergeValue(object, key, newValue);
} }

View File

@@ -14,12 +14,8 @@ import compareMultiple from './_compareMultiple';
* @returns {Array} Returns the new sorted array. * @returns {Array} Returns the new sorted array.
*/ */
function baseOrderBy(collection, iteratees, orders) { function baseOrderBy(collection, iteratees, orders) {
var index = -1, var index = -1;
toIteratee = baseIteratee; iteratees = arrayMap(iteratees.length ? iteratees : Array(1), baseIteratee);
iteratees = arrayMap(iteratees.length ? iteratees : Array(1), function(iteratee) {
return toIteratee(iteratee);
});
var result = baseMap(collection, function(value, key, collection) { var result = baseMap(collection, function(value, key, collection) {
var criteria = arrayMap(iteratees, function(iteratee) { var criteria = arrayMap(iteratees, function(iteratee) {

View File

@@ -1,15 +1,47 @@
import basePullAllBy from './_basePullAllBy'; import arrayMap from './_arrayMap';
import baseIndexOf from './_baseIndexOf';
import baseIndexOfWith from './_baseIndexOfWith';
import baseUnary from './_baseUnary';
/** Used for built-in method references. */
var arrayProto = Array.prototype;
/** Built-in value references. */
var splice = arrayProto.splice;
/** /**
* The base implementation of `_.pullAll`. * The base implementation of `_.pullAllBy` without support for iteratee
* shorthands.
* *
* @private * @private
* @param {Array} array The array to modify. * @param {Array} array The array to modify.
* @param {Array} values The values to remove. * @param {Array} values The values to remove.
* @param {Function} [iteratee] The iteratee invoked per element.
* @param {Function} [comparator] The comparator invoked per element.
* @returns {Array} Returns `array`. * @returns {Array} Returns `array`.
*/ */
function basePullAll(array, values) { function basePullAll(array, values, iteratee, comparator) {
return basePullAllBy(array, values); var indexOf = comparator ? baseIndexOfWith : baseIndexOf,
index = -1,
length = values.length,
seen = array;
if (iteratee) {
seen = arrayMap(array, baseUnary(iteratee));
}
while (++index < length) {
var fromIndex = 0,
value = values[index],
computed = iteratee ? iteratee(value) : value;
while ((fromIndex = indexOf(seen, computed, fromIndex, comparator)) > -1) {
if (seen !== array) {
splice.call(seen, fromIndex, 1);
}
splice.call(array, fromIndex, 1);
}
}
return array;
} }
export default basePullAll; export default basePullAll;

View File

@@ -1,43 +0,0 @@
import arrayMap from './_arrayMap';
import baseIndexOf from './_baseIndexOf';
/** Used for built-in method references. */
var arrayProto = Array.prototype;
/** Built-in value references. */
var splice = arrayProto.splice;
/**
* The base implementation of `_.pullAllBy` without support for iteratee
* shorthands.
*
* @private
* @param {Array} array The array to modify.
* @param {Array} values The values to remove.
* @param {Function} [iteratee] The iteratee invoked per element.
* @returns {Array} Returns `array`.
*/
function basePullAllBy(array, values, iteratee) {
var index = -1,
length = values.length,
seen = array;
if (iteratee) {
seen = arrayMap(array, function(value) { return iteratee(value); });
}
while (++index < length) {
var fromIndex = 0,
value = values[index],
computed = iteratee ? iteratee(value) : value;
while ((fromIndex = baseIndexOf(seen, computed, fromIndex)) > -1) {
if (seen !== array) {
splice.call(seen, fromIndex, 1);
}
splice.call(array, fromIndex, 1);
}
}
return array;
}
export default basePullAllBy;

View File

@@ -1,7 +1,7 @@
/** /**
* The base implementation of `_.sortBy` which uses `comparer` to define * The base implementation of `_.sortBy` which uses `comparer` to define the
* the sort order of `array` and replaces criteria objects with their * sort order of `array` and replaces criteria objects with their corresponding
* corresponding values. * values.
* *
* @private * @private
* @param {Array} array The array to sort. * @param {Array} array The array to sort.

View File

@@ -15,7 +15,7 @@ function baseSortedUniqBy(array, iteratee) {
value = array[0], value = array[0],
computed = iteratee ? iteratee(value) : value, computed = iteratee ? iteratee(value) : value,
seen = computed, seen = computed,
resIndex = 0, resIndex = 1,
result = [value]; result = [value];
while (++index < length) { while (++index < length) {
@@ -24,7 +24,7 @@ function baseSortedUniqBy(array, iteratee) {
if (!eq(computed, seen)) { if (!eq(computed, seen)) {
seen = computed; seen = computed;
result[++resIndex] = value; result[resIndex++] = value;
} }
} }
return result; return result;

18
_baseUpdate.js Normal file
View File

@@ -0,0 +1,18 @@
import baseGet from './_baseGet';
import baseSet from './_baseSet';
/**
* The base implementation of `_.update`.
*
* @private
* @param {Object} object The object to query.
* @param {Array|string} path The path of the property to update.
* @param {Function} updater The function to produce the updated value.
* @param {Function} [customizer] The function to customize path creation.
* @returns {Object} Returns `object`.
*/
function baseUpdate(object, path, updater, customizer) {
return baseSet(object, path, updater(baseGet(object, path)), customizer);
}
export default baseUpdate;

View File

@@ -8,11 +8,8 @@ import Uint8Array from './_Uint8Array';
* @returns {ArrayBuffer} Returns the cloned array buffer. * @returns {ArrayBuffer} Returns the cloned array buffer.
*/ */
function cloneArrayBuffer(arrayBuffer) { function cloneArrayBuffer(arrayBuffer) {
var Ctor = arrayBuffer.constructor, var result = new arrayBuffer.constructor(arrayBuffer.byteLength);
result = new Ctor(arrayBuffer.byteLength), new Uint8Array(result).set(new Uint8Array(arrayBuffer));
view = new Uint8Array(result);
view.set(new Uint8Array(arrayBuffer));
return result; return result;
} }

View File

@@ -10,9 +10,7 @@ function cloneBuffer(buffer, isDeep) {
if (isDeep) { if (isDeep) {
return buffer.slice(); return buffer.slice();
} }
var Ctor = buffer.constructor, var result = new buffer.constructor(buffer.length);
result = new Ctor(buffer.length);
buffer.copy(result); buffer.copy(result);
return result; return result;
} }

View File

@@ -10,8 +10,7 @@ import mapToArray from './_mapToArray';
* @returns {Object} Returns the cloned map. * @returns {Object} Returns the cloned map.
*/ */
function cloneMap(map) { function cloneMap(map) {
var Ctor = map.constructor; return arrayReduce(mapToArray(map), addMapEntry, new map.constructor);
return arrayReduce(mapToArray(map), addMapEntry, new Ctor);
} }
export default cloneMap; export default cloneMap;

View File

@@ -9,9 +9,7 @@ var reFlags = /\w*$/;
* @returns {Object} Returns the cloned regexp. * @returns {Object} Returns the cloned regexp.
*/ */
function cloneRegExp(regexp) { function cloneRegExp(regexp) {
var Ctor = regexp.constructor, var result = new regexp.constructor(regexp.source, reFlags.exec(regexp));
result = new Ctor(regexp.source, reFlags.exec(regexp));
result.lastIndex = regexp.lastIndex; result.lastIndex = regexp.lastIndex;
return result; return result;
} }

View File

@@ -10,8 +10,7 @@ import setToArray from './_setToArray';
* @returns {Object} Returns the cloned set. * @returns {Object} Returns the cloned set.
*/ */
function cloneSet(set) { function cloneSet(set) {
var Ctor = set.constructor; return arrayReduce(setToArray(set), addSetEntry, new set.constructor);
return arrayReduce(setToArray(set), addSetEntry, new Ctor);
} }
export default cloneSet; export default cloneSet;

View File

@@ -2,7 +2,7 @@ import Symbol from './_Symbol';
/** Used to convert symbols to primitives and strings. */ /** Used to convert symbols to primitives and strings. */
var symbolProto = Symbol ? Symbol.prototype : undefined, var symbolProto = Symbol ? Symbol.prototype : undefined,
symbolValueOf = Symbol ? symbolProto.valueOf : undefined; symbolValueOf = symbolProto ? symbolProto.valueOf : undefined;
/** /**
* Creates a clone of the `symbol` object. * Creates a clone of the `symbol` object.
@@ -12,7 +12,7 @@ var symbolProto = Symbol ? Symbol.prototype : undefined,
* @returns {Object} Returns the cloned symbol object. * @returns {Object} Returns the cloned symbol object.
*/ */
function cloneSymbol(symbol) { function cloneSymbol(symbol) {
return Symbol ? Object(symbolValueOf.call(symbol)) : {}; return symbolValueOf ? Object(symbolValueOf.call(symbol)) : {};
} }
export default cloneSymbol; export default cloneSymbol;

View File

@@ -9,11 +9,8 @@ import cloneArrayBuffer from './_cloneArrayBuffer';
* @returns {Object} Returns the cloned typed array. * @returns {Object} Returns the cloned typed array.
*/ */
function cloneTypedArray(typedArray, isDeep) { function cloneTypedArray(typedArray, isDeep) {
var arrayBuffer = typedArray.buffer, var buffer = isDeep ? cloneArrayBuffer(typedArray.buffer) : typedArray.buffer;
buffer = isDeep ? cloneArrayBuffer(arrayBuffer) : arrayBuffer, return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length);
Ctor = typedArray.constructor;
return new Ctor(buffer, typedArray.byteOffset, typedArray.length);
} }
export default cloneTypedArray; export default cloneTypedArray;

View File

@@ -9,23 +9,28 @@ var nativeMax = Math.max;
* @param {Array|Object} args The provided arguments. * @param {Array|Object} args The provided arguments.
* @param {Array} partials The arguments to prepend to those provided. * @param {Array} partials The arguments to prepend to those provided.
* @param {Array} holders The `partials` placeholder indexes. * @param {Array} holders The `partials` placeholder indexes.
* @params {boolean} [isCurried] Specify composing for a curried function.
* @returns {Array} Returns the new array of composed arguments. * @returns {Array} Returns the new array of composed arguments.
*/ */
function composeArgs(args, partials, holders) { function composeArgs(args, partials, holders, isCurried) {
var holdersLength = holders.length, var argsIndex = -1,
argsIndex = -1, argsLength = args.length,
argsLength = nativeMax(args.length - holdersLength, 0), holdersLength = holders.length,
leftIndex = -1, leftIndex = -1,
leftLength = partials.length, leftLength = partials.length,
result = Array(leftLength + argsLength); rangeLength = nativeMax(argsLength - holdersLength, 0),
result = Array(leftLength + rangeLength),
isUncurried = !isCurried;
while (++leftIndex < leftLength) { while (++leftIndex < leftLength) {
result[leftIndex] = partials[leftIndex]; result[leftIndex] = partials[leftIndex];
} }
while (++argsIndex < holdersLength) { while (++argsIndex < holdersLength) {
result[holders[argsIndex]] = args[argsIndex]; if (isUncurried || argsIndex < argsLength) {
result[holders[argsIndex]] = args[argsIndex];
}
} }
while (argsLength--) { while (rangeLength--) {
result[leftIndex++] = args[argsIndex++]; result[leftIndex++] = args[argsIndex++];
} }
return result; return result;

View File

@@ -9,18 +9,21 @@ var nativeMax = Math.max;
* @param {Array|Object} args The provided arguments. * @param {Array|Object} args The provided arguments.
* @param {Array} partials The arguments to append to those provided. * @param {Array} partials The arguments to append to those provided.
* @param {Array} holders The `partials` placeholder indexes. * @param {Array} holders The `partials` placeholder indexes.
* @params {boolean} [isCurried] Specify composing for a curried function.
* @returns {Array} Returns the new array of composed arguments. * @returns {Array} Returns the new array of composed arguments.
*/ */
function composeArgsRight(args, partials, holders) { function composeArgsRight(args, partials, holders, isCurried) {
var holdersIndex = -1, var argsIndex = -1,
argsLength = args.length,
holdersIndex = -1,
holdersLength = holders.length, holdersLength = holders.length,
argsIndex = -1,
argsLength = nativeMax(args.length - holdersLength, 0),
rightIndex = -1, rightIndex = -1,
rightLength = partials.length, rightLength = partials.length,
result = Array(argsLength + rightLength); rangeLength = nativeMax(argsLength - holdersLength, 0),
result = Array(rangeLength + rightLength),
isUncurried = !isCurried;
while (++argsIndex < argsLength) { while (++argsIndex < rangeLength) {
result[argsIndex] = args[argsIndex]; result[argsIndex] = args[argsIndex];
} }
var offset = argsIndex; var offset = argsIndex;
@@ -28,7 +31,9 @@ function composeArgsRight(args, partials, holders) {
result[offset + rightIndex] = partials[rightIndex]; result[offset + rightIndex] = partials[rightIndex];
} }
while (++holdersIndex < holdersLength) { while (++holdersIndex < holdersLength) {
result[offset + holders[holdersIndex]] = args[argsIndex++]; if (isUncurried || argsIndex < argsLength) {
result[offset + holders[holdersIndex]] = args[argsIndex++];
}
} }
return result; return result;
} }

21
_countHolders.js Normal file
View File

@@ -0,0 +1,21 @@
/**
* Gets the number of `placeholder` occurrences in `array`.
*
* @private
* @param {Array} array The array to inspect.
* @param {*} placeholder The placeholder to search for.
* @returns {number} Returns the placeholder count.
*/
function countHolders(array, placeholder) {
var length = array.length,
result = 0;
while (length--) {
if (array[length] === placeholder) {
result++;
}
}
return result;
}
export default countHolders;

View File

@@ -2,6 +2,7 @@ import apply from './_apply';
import createCtorWrapper from './_createCtorWrapper'; import createCtorWrapper from './_createCtorWrapper';
import createHybridWrapper from './_createHybridWrapper'; import createHybridWrapper from './_createHybridWrapper';
import createRecurryWrapper from './_createRecurryWrapper'; import createRecurryWrapper from './_createRecurryWrapper';
import getPlaceholder from './_getPlaceholder';
import replaceHolders from './_replaceHolders'; import replaceHolders from './_replaceHolders';
import root from './_root'; import root from './_root';
@@ -19,10 +20,9 @@ function createCurryWrapper(func, bitmask, arity) {
function wrapper() { function wrapper() {
var length = arguments.length, var length = arguments.length,
index = length,
args = Array(length), args = Array(length),
fn = (this && this !== root && this instanceof wrapper) ? Ctor : func, index = length,
placeholder = wrapper.placeholder; placeholder = getPlaceholder(wrapper);
while (index--) { while (index--) {
args[index] = arguments[index]; args[index] = arguments[index];
@@ -32,9 +32,13 @@ function createCurryWrapper(func, bitmask, arity) {
: replaceHolders(args, placeholder); : replaceHolders(args, placeholder);
length -= holders.length; length -= holders.length;
return length < arity if (length < arity) {
? createRecurryWrapper(func, bitmask, createHybridWrapper, placeholder, undefined, args, holders, undefined, undefined, arity - length) return createRecurryWrapper(
: apply(fn, this, args); func, bitmask, createHybridWrapper, wrapper.placeholder, undefined,
args, holders, undefined, undefined, arity - length);
}
var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
return apply(fn, this, args);
} }
return wrapper; return wrapper;
} }

View File

@@ -6,18 +6,18 @@ import isArray from './isArray';
import isLaziable from './_isLaziable'; import isLaziable from './_isLaziable';
import rest from './rest'; import rest from './rest';
/** Used to compose bitmasks for wrapper metadata. */
var CURRY_FLAG = 8,
PARTIAL_FLAG = 32,
ARY_FLAG = 128,
REARG_FLAG = 256;
/** Used as the size to enable large array optimizations. */ /** Used as the size to enable large array optimizations. */
var LARGE_ARRAY_SIZE = 200; var LARGE_ARRAY_SIZE = 200;
/** Used as the `TypeError` message for "Functions" methods. */ /** Used as the `TypeError` message for "Functions" methods. */
var FUNC_ERROR_TEXT = 'Expected a function'; var FUNC_ERROR_TEXT = 'Expected a function';
/** Used to compose bitmasks for wrapper metadata. */
var CURRY_FLAG = 8,
PARTIAL_FLAG = 32,
ARY_FLAG = 128,
REARG_FLAG = 256;
/** /**
* Creates a `_.flow` or `_.flowRight` function. * Creates a `_.flow` or `_.flowRight` function.
* *

View File

@@ -1,7 +1,9 @@
import composeArgs from './_composeArgs'; import composeArgs from './_composeArgs';
import composeArgsRight from './_composeArgsRight'; import composeArgsRight from './_composeArgsRight';
import countHolders from './_countHolders';
import createCtorWrapper from './_createCtorWrapper'; import createCtorWrapper from './_createCtorWrapper';
import createRecurryWrapper from './_createRecurryWrapper'; import createRecurryWrapper from './_createRecurryWrapper';
import getPlaceholder from './_getPlaceholder';
import reorder from './_reorder'; import reorder from './_reorder';
import replaceHolders from './_replaceHolders'; import replaceHolders from './_replaceHolders';
import root from './_root'; import root from './_root';
@@ -35,8 +37,7 @@ function createHybridWrapper(func, bitmask, thisArg, partials, holders, partials
var isAry = bitmask & ARY_FLAG, var isAry = bitmask & ARY_FLAG,
isBind = bitmask & BIND_FLAG, isBind = bitmask & BIND_FLAG,
isBindKey = bitmask & BIND_KEY_FLAG, isBindKey = bitmask & BIND_KEY_FLAG,
isCurry = bitmask & CURRY_FLAG, isCurried = bitmask & (CURRY_FLAG | CURRY_RIGHT_FLAG),
isCurryRight = bitmask & CURRY_RIGHT_FLAG,
isFlip = bitmask & FLIP_FLAG, isFlip = bitmask & FLIP_FLAG,
Ctor = isBindKey ? undefined : createCtorWrapper(func); Ctor = isBindKey ? undefined : createCtorWrapper(func);
@@ -48,33 +49,34 @@ function createHybridWrapper(func, bitmask, thisArg, partials, holders, partials
while (index--) { while (index--) {
args[index] = arguments[index]; args[index] = arguments[index];
} }
if (isCurried) {
var placeholder = getPlaceholder(wrapper),
holdersCount = countHolders(args, placeholder);
}
if (partials) { if (partials) {
args = composeArgs(args, partials, holders); args = composeArgs(args, partials, holders, isCurried);
} }
if (partialsRight) { if (partialsRight) {
args = composeArgsRight(args, partialsRight, holdersRight); args = composeArgsRight(args, partialsRight, holdersRight, isCurried);
} }
if (isCurry || isCurryRight) { length -= holdersCount;
var placeholder = wrapper.placeholder, if (isCurried && length < arity) {
argsHolders = replaceHolders(args, placeholder); var newHolders = replaceHolders(args, placeholder);
return createRecurryWrapper(
length -= argsHolders.length; func, bitmask, createHybridWrapper, wrapper.placeholder, thisArg,
if (length < arity) { args, newHolders, argPos, ary, arity - length
return createRecurryWrapper( );
func, bitmask, createHybridWrapper, placeholder, thisArg, args,
argsHolders, argPos, ary, arity - length
);
}
} }
var thisBinding = isBind ? thisArg : this, var thisBinding = isBind ? thisArg : this,
fn = isBindKey ? thisBinding[func] : func; fn = isBindKey ? thisBinding[func] : func;
length = args.length;
if (argPos) { if (argPos) {
args = reorder(args, argPos); args = reorder(args, argPos);
} else if (isFlip && args.length > 1) { } else if (isFlip && length > 1) {
args.reverse(); args.reverse();
} }
if (isAry && ary < args.length) { if (isAry && ary < length) {
args.length = ary; args.length = ary;
} }
if (this && this !== root && this instanceof wrapper) { if (this && this !== root && this instanceof wrapper) {

View File

@@ -17,7 +17,7 @@ var BIND_FLAG = 1,
* @param {Function} func The function to wrap. * @param {Function} func The function to wrap.
* @param {number} bitmask The bitmask of wrapper flags. See `createWrapper` for more details. * @param {number} bitmask The bitmask of wrapper flags. See `createWrapper` for more details.
* @param {Function} wrapFunc The function to create the `func` wrapper. * @param {Function} wrapFunc The function to create the `func` wrapper.
* @param {*} placeholder The placeholder to replace. * @param {*} placeholder The placeholder value.
* @param {*} [thisArg] The `this` binding of `func`. * @param {*} [thisArg] The `this` binding of `func`.
* @param {Array} [partials] The arguments to prepend to those provided to the new function. * @param {Array} [partials] The arguments to prepend to those provided to the new function.
* @param {Array} [holders] The `partials` placeholder indexes. * @param {Array} [holders] The `partials` placeholder indexes.
@@ -29,7 +29,7 @@ var BIND_FLAG = 1,
function createRecurryWrapper(func, bitmask, wrapFunc, placeholder, thisArg, partials, holders, argPos, ary, arity) { function createRecurryWrapper(func, bitmask, wrapFunc, placeholder, thisArg, partials, holders, argPos, ary, arity) {
var isCurry = bitmask & CURRY_FLAG, var isCurry = bitmask & CURRY_FLAG,
newArgPos = argPos ? copyArray(argPos) : undefined, newArgPos = argPos ? copyArray(argPos) : undefined,
newsHolders = 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;
@@ -41,7 +41,7 @@ function createRecurryWrapper(func, bitmask, wrapFunc, placeholder, thisArg, par
bitmask &= ~(BIND_FLAG | BIND_KEY_FLAG); bitmask &= ~(BIND_FLAG | BIND_KEY_FLAG);
} }
var newData = [ var newData = [
func, bitmask, thisArg, newPartials, newsHolders, newPartialsRight, func, bitmask, thisArg, newPartials, newHolders, newPartialsRight,
newHoldersRight, newArgPos, ary, arity newHoldersRight, newArgPos, ary, arity
]; ];

View File

@@ -8,6 +8,9 @@ import mergeData from './_mergeData';
import setData from './_setData'; import setData from './_setData';
import toInteger from './toInteger'; import toInteger from './toInteger';
/** Used as the `TypeError` message for "Functions" methods. */
var FUNC_ERROR_TEXT = 'Expected a function';
/** Used to compose bitmasks for wrapper metadata. */ /** Used to compose bitmasks for wrapper metadata. */
var BIND_FLAG = 1, var BIND_FLAG = 1,
BIND_KEY_FLAG = 2, BIND_KEY_FLAG = 2,
@@ -16,9 +19,6 @@ var BIND_FLAG = 1,
PARTIAL_FLAG = 32, PARTIAL_FLAG = 32,
PARTIAL_RIGHT_FLAG = 64; PARTIAL_RIGHT_FLAG = 64;
/** Used as the `TypeError` message for "Functions" methods. */
var FUNC_ERROR_TEXT = 'Expected a function';
/* Built-in method references for those with the same name as other `lodash` methods. */ /* Built-in method references for those with the same name as other `lodash` methods. */
var nativeMax = Math.max; var nativeMax = Math.max;

View File

@@ -12,9 +12,9 @@ var UNORDERED_COMPARE_FLAG = 1,
* @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 {Function} equalFunc The function to determine equivalents of values.
* @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` for more details. * @param {number} bitmask The bitmask of comparison flags. See `baseIsEqual` 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, equalFunc, customizer, bitmask, stack) {

View File

@@ -1,5 +1,6 @@
import Symbol from './_Symbol'; import Symbol from './_Symbol';
import Uint8Array from './_Uint8Array'; import Uint8Array from './_Uint8Array';
import equalArrays from './_equalArrays';
import mapToArray from './_mapToArray'; import mapToArray from './_mapToArray';
import setToArray from './_setToArray'; import setToArray from './_setToArray';
@@ -22,7 +23,7 @@ var arrayBufferTag = '[object ArrayBuffer]';
/** Used to convert symbols to primitives and strings. */ /** Used to convert symbols to primitives and strings. */
var symbolProto = Symbol ? Symbol.prototype : undefined, var symbolProto = Symbol ? Symbol.prototype : undefined,
symbolValueOf = Symbol ? symbolProto.valueOf : undefined; symbolValueOf = symbolProto ? symbolProto.valueOf : undefined;
/** /**
* A specialized version of `baseIsEqualDeep` for comparing objects of * A specialized version of `baseIsEqualDeep` for comparing objects of
@@ -36,11 +37,12 @@ var symbolProto = Symbol ? Symbol.prototype : undefined,
* @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 {Function} equalFunc The function to determine equivalents of values.
* @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` for more details. * @param {number} bitmask The bitmask of comparison flags. See `baseIsEqual` for more details.
* @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) { function equalByTag(object, other, tag, equalFunc, customizer, bitmask, stack) {
switch (tag) { switch (tag) {
case arrayBufferTag: case arrayBufferTag:
if ((object.byteLength != other.byteLength) || if ((object.byteLength != other.byteLength) ||
@@ -75,12 +77,21 @@ function equalByTag(object, other, tag, equalFunc, customizer, bitmask) {
var isPartial = bitmask & PARTIAL_COMPARE_FLAG; var isPartial = bitmask & PARTIAL_COMPARE_FLAG;
convert || (convert = setToArray); convert || (convert = setToArray);
if (object.size != other.size && !isPartial) {
return false;
}
// Assume cyclic values are equal.
var stacked = stack.get(object);
if (stacked) {
return stacked == other;
}
// Recursively compare objects (susceptible to call stack limits). // Recursively compare objects (susceptible to call stack limits).
return (isPartial || object.size == other.size) && return equalArrays(convert(object), convert(other), equalFunc, customizer, bitmask | UNORDERED_COMPARE_FLAG, stack.set(object, other));
equalFunc(convert(object), convert(other), customizer, bitmask | UNORDERED_COMPARE_FLAG);
case symbolTag: case symbolTag:
return !!Symbol && (symbolValueOf.call(object) == symbolValueOf.call(other)); if (symbolValueOf) {
return symbolValueOf.call(object) == symbolValueOf.call(other);
}
} }
return false; return false;
} }

View File

@@ -12,9 +12,9 @@ var PARTIAL_COMPARE_FLAG = 2;
* @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 {Function} equalFunc The function to determine equivalents of values.
* @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` for more details. * @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 equalObjects(object, other, equalFunc, customizer, bitmask, stack) { function equalObjects(object, other, equalFunc, customizer, bitmask, stack) {

View File

@@ -9,7 +9,7 @@ import isNative from './isNative';
* @returns {*} Returns the function if it's native, else `undefined`. * @returns {*} Returns the function if it's native, else `undefined`.
*/ */
function getNative(object, key) { function getNative(object, key) {
var value = object == null ? undefined : object[key]; var value = object[key];
return isNative(value) ? value : undefined; return isNative(value) ? value : undefined;
} }

13
_getPlaceholder.js Normal file
View File

@@ -0,0 +1,13 @@
/**
* Gets the argument placeholder value for `func`.
*
* @private
* @param {Function} func The function to inspect.
* @returns {*} Returns the placeholder value.
*/
function getPlaceholder(func) {
var object = func;
return object.placeholder;
}
export default getPlaceholder;

View File

@@ -1,7 +1,9 @@
import baseCreate from './_baseCreate'; import baseCreate from './_baseCreate';
import isFunction from './isFunction';
import isPrototype from './_isPrototype'; import isPrototype from './_isPrototype';
/** Built-in value references. */
var getPrototypeOf = Object.getPrototypeOf;
/** /**
* Initializes an object clone. * Initializes an object clone.
* *
@@ -10,11 +12,9 @@ import isPrototype from './_isPrototype';
* @returns {Object} Returns the initialized clone. * @returns {Object} Returns the initialized clone.
*/ */
function initCloneObject(object) { function initCloneObject(object) {
if (isPrototype(object)) { return (typeof object.constructor == 'function' && !isPrototype(object))
return {}; ? baseCreate(getPrototypeOf(object))
} : {};
var Ctor = object.constructor;
return baseCreate(isFunction(Ctor) ? Ctor.prototype : undefined);
} }
export default initCloneObject; export default initCloneObject;

View File

@@ -3,6 +3,9 @@ import composeArgsRight from './_composeArgsRight';
import copyArray from './_copyArray'; import copyArray from './_copyArray';
import replaceHolders from './_replaceHolders'; import replaceHolders from './_replaceHolders';
/** Used as the internal argument placeholder. */
var PLACEHOLDER = '__lodash_placeholder__';
/** Used to compose bitmasks for wrapper metadata. */ /** Used to compose bitmasks for wrapper metadata. */
var BIND_FLAG = 1, var BIND_FLAG = 1,
BIND_KEY_FLAG = 2, BIND_KEY_FLAG = 2,
@@ -11,9 +14,6 @@ var BIND_FLAG = 1,
ARY_FLAG = 128, ARY_FLAG = 128,
REARG_FLAG = 256; REARG_FLAG = 256;
/** Used as the internal argument placeholder. */
var PLACEHOLDER = '__lodash_placeholder__';
/* Built-in method references for those with the same name as other `lodash` methods. */ /* Built-in method references for those with the same name as other `lodash` methods. */
var nativeMin = Math.min; var nativeMin = Math.min;
@@ -39,9 +39,9 @@ function mergeData(data, source) {
isCommon = newBitmask < (BIND_FLAG | BIND_KEY_FLAG | ARY_FLAG); isCommon = newBitmask < (BIND_FLAG | BIND_KEY_FLAG | ARY_FLAG);
var isCombo = var isCombo =
(srcBitmask == ARY_FLAG && (bitmask == CURRY_FLAG)) || ((srcBitmask == ARY_FLAG) && (bitmask == CURRY_FLAG)) ||
(srcBitmask == ARY_FLAG && (bitmask == REARG_FLAG) && (data[7].length <= source[8])) || ((srcBitmask == ARY_FLAG) && (bitmask == REARG_FLAG) && (data[7].length <= source[8])) ||
(srcBitmask == (ARY_FLAG | REARG_FLAG) && (source[7].length <= source[8]) && (bitmask == CURRY_FLAG)); ((srcBitmask == (ARY_FLAG | REARG_FLAG)) && (source[7].length <= source[8]) && (bitmask == CURRY_FLAG));
// Exit early if metadata can't be merged. // Exit early if metadata can't be merged.
if (!(isCommon || isCombo)) { if (!(isCommon || isCombo)) {
@@ -51,7 +51,7 @@ function mergeData(data, source) {
if (srcBitmask & BIND_FLAG) { if (srcBitmask & 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 & BIND_FLAG ? 0 : CURRY_BOUND_FLAG;
} }
// Compose partial arguments. // Compose partial arguments.
var value = source[3]; var value = source[3];

View File

@@ -15,8 +15,7 @@ import isObject from './isObject';
*/ */
function mergeDefaults(objValue, srcValue, key, object, source, stack) { function mergeDefaults(objValue, srcValue, key, object, source, stack) {
if (isObject(objValue) && isObject(srcValue)) { if (isObject(objValue) && isObject(srcValue)) {
stack.set(srcValue, objValue); baseMerge(objValue, srcValue, undefined, mergeDefaults, stack.set(srcValue, objValue));
baseMerge(objValue, srcValue, undefined, mergeDefaults, stack);
} }
return objValue; return objValue;
} }

View File

@@ -13,13 +13,14 @@ var PLACEHOLDER = '__lodash_placeholder__';
function replaceHolders(array, placeholder) { function replaceHolders(array, placeholder) {
var index = -1, var index = -1,
length = array.length, length = array.length,
resIndex = -1, resIndex = 0,
result = []; result = [];
while (++index < length) { while (++index < length) {
if (array[index] === placeholder) { var value = array[index];
if (value === placeholder || value === PLACEHOLDER) {
array[index] = PLACEHOLDER; array[index] = PLACEHOLDER;
result[++resIndex] = index; result[resIndex++] = index;
} }
} }
return result; return result;

View File

@@ -27,6 +27,7 @@ import lastIndexOf from './lastIndexOf';
import pull from './pull'; import pull from './pull';
import pullAll from './pullAll'; import pullAll from './pullAll';
import pullAllBy from './pullAllBy'; import pullAllBy from './pullAllBy';
import pullAllWith from './pullAllWith';
import pullAt from './pullAt'; import pullAt from './pullAt';
import remove from './remove'; import remove from './remove';
import reverse from './reverse'; import reverse from './reverse';
@@ -67,12 +68,12 @@ export default {
fill, findIndex, findLastIndex, flatten, flattenDeep, fill, findIndex, findLastIndex, flatten, flattenDeep,
flattenDepth, fromPairs, head, indexOf, initial, flattenDepth, fromPairs, head, indexOf, initial,
intersection, intersectionBy, intersectionWith, join, last, intersection, intersectionBy, intersectionWith, join, last,
lastIndexOf, pull, pullAll, pullAllBy, pullAt, lastIndexOf, pull, pullAll, pullAllBy, pullAllWith,
remove, reverse, slice, sortedIndex, sortedIndexBy, pullAt, remove, reverse, slice, sortedIndex,
sortedIndexOf, sortedLastIndex, sortedLastIndexBy, sortedLastIndexOf, sortedUniq, sortedIndexBy, sortedIndexOf, sortedLastIndex, sortedLastIndexBy, sortedLastIndexOf,
sortedUniqBy, tail, take, takeRight, takeRightWhile, sortedUniq, sortedUniqBy, tail, take, takeRight,
takeWhile, union, unionBy, unionWith, uniq, takeRightWhile, takeWhile, union, unionBy, unionWith,
uniqBy, uniqWith, unzip, unzipWith, without, uniq, uniqBy, uniqWith, unzip, unzipWith,
xor, xorBy, xorWith, zip, zipObject, without, xor, xorBy, xorWith, zip,
zipObjectDeep, zipWith zipObject, zipObjectDeep, zipWith
}; };

View File

@@ -27,6 +27,7 @@ export { default as lastIndexOf } from './lastIndexOf';
export { default as pull } from './pull'; export { default as pull } from './pull';
export { default as pullAll } from './pullAll'; export { default as pullAll } from './pullAll';
export { default as pullAllBy } from './pullAllBy'; export { default as pullAllBy } from './pullAllBy';
export { default as pullAllWith } from './pullAllWith';
export { default as pullAt } from './pullAt'; export { default as pullAt } from './pullAt';
export { default as remove } from './remove'; export { default as remove } from './remove';
export { default as reverse } from './reverse'; export { default as reverse } from './reverse';

View File

@@ -1,7 +1,19 @@
import assignValue from './_assignValue';
import copyObject from './_copyObject'; import copyObject from './_copyObject';
import createAssigner from './_createAssigner'; import createAssigner from './_createAssigner';
import isArrayLike from './isArrayLike';
import isPrototype from './_isPrototype';
import keys from './keys'; import keys from './keys';
/** Used for built-in method references. */
var objectProto = Object.prototype;
/** Used to check objects for own properties. */
var hasOwnProperty = objectProto.hasOwnProperty;
/** Detect if properties shadowing those on `Object.prototype` are non-enumerable. */
var nonEnumShadows = !({ 'valueOf': 1 }).propertyIsEnumerable('valueOf');
/** /**
* Assigns own enumerable properties of source objects to the destination * Assigns own enumerable properties of source objects to the destination
* object. Source objects are applied from left to right. Subsequent sources * object. Source objects are applied from left to right. Subsequent sources
@@ -33,7 +45,15 @@ import keys from './keys';
* // => { 'a': 1, 'c': 3, 'e': 5 } * // => { 'a': 1, 'c': 3, 'e': 5 }
*/ */
var assign = createAssigner(function(object, source) { var assign = createAssigner(function(object, source) {
copyObject(source, keys(source), object); if (nonEnumShadows || isPrototype(source) || isArrayLike(source)) {
copyObject(source, keys(source), object);
return;
}
for (var key in source) {
if (hasOwnProperty.call(source, key)) {
assignValue(object, key, source[key]);
}
}
}); });
export default assign; export default assign;

View File

@@ -1,7 +1,13 @@
import assignValue from './_assignValue';
import copyObject from './_copyObject'; import copyObject from './_copyObject';
import createAssigner from './_createAssigner'; import createAssigner from './_createAssigner';
import isArrayLike from './isArrayLike';
import isPrototype from './_isPrototype';
import keysIn from './keysIn'; import keysIn from './keysIn';
/** Detect if properties shadowing those on `Object.prototype` are non-enumerable. */
var nonEnumShadows = !({ 'valueOf': 1 }).propertyIsEnumerable('valueOf');
/** /**
* This method is like `_.assign` except that it iterates over own and * This method is like `_.assign` except that it iterates over own and
* inherited source properties. * inherited source properties.
@@ -32,7 +38,13 @@ import keysIn from './keysIn';
* // => { 'a': 1, 'b': 2, 'c': 3, 'd': 4, 'e': 5 } * // => { 'a': 1, 'b': 2, 'c': 3, 'd': 4, 'e': 5 }
*/ */
var assignIn = createAssigner(function(object, source) { var assignIn = createAssigner(function(object, source) {
copyObject(source, keysIn(source), object); if (nonEnumShadows || isPrototype(source) || isArrayLike(source)) {
copyObject(source, keysIn(source), object);
return;
}
for (var key in source) {
assignValue(object, key, source[key]);
}
}); });
export default assignIn; export default assignIn;

View File

@@ -1,4 +1,5 @@
import createWrapper from './_createWrapper'; import createWrapper from './_createWrapper';
import getPlaceholder from './_getPlaceholder';
import replaceHolders from './_replaceHolders'; import replaceHolders from './_replaceHolders';
import rest from './rest'; import rest from './rest';
@@ -44,9 +45,7 @@ var BIND_FLAG = 1,
var bind = rest(function(func, thisArg, partials) { var bind = rest(function(func, thisArg, partials) {
var bitmask = BIND_FLAG; var bitmask = BIND_FLAG;
if (partials.length) { if (partials.length) {
var placeholder = bind.placeholder, var holders = replaceHolders(partials, getPlaceholder(bind));
holders = replaceHolders(partials, placeholder);
bitmask |= PARTIAL_FLAG; bitmask |= PARTIAL_FLAG;
} }
return createWrapper(func, bitmask, thisArg, partials, holders); return createWrapper(func, bitmask, thisArg, partials, holders);

View File

@@ -1,4 +1,5 @@
import createWrapper from './_createWrapper'; import createWrapper from './_createWrapper';
import getPlaceholder from './_getPlaceholder';
import replaceHolders from './_replaceHolders'; import replaceHolders from './_replaceHolders';
import rest from './rest'; import rest from './rest';
@@ -54,9 +55,7 @@ var BIND_FLAG = 1,
var bindKey = rest(function(object, key, partials) { var bindKey = rest(function(object, key, partials) {
var bitmask = BIND_FLAG | BIND_KEY_FLAG; var bitmask = BIND_FLAG | BIND_KEY_FLAG;
if (partials.length) { if (partials.length) {
var placeholder = bindKey.placeholder, var holders = replaceHolders(partials, getPlaceholder(bindKey));
holders = replaceHolders(partials, placeholder);
bitmask |= PARTIAL_FLAG; bitmask |= PARTIAL_FLAG;
} }
return createWrapper(key, bitmask, object, partials, holders); return createWrapper(key, bitmask, object, partials, holders);

View File

@@ -32,11 +32,11 @@ function chunk(array, size) {
return []; return [];
} }
var index = 0, var index = 0,
resIndex = -1, resIndex = 0,
result = Array(nativeCeil(length / size)); result = Array(nativeCeil(length / size));
while (index < length) { while (index < length) {
result[++resIndex] = baseSlice(array, index, (index += size)); result[resIndex++] = baseSlice(array, index, (index += size));
} }
return result; return result;
} }

View File

@@ -15,13 +15,13 @@
function compact(array) { function compact(array) {
var index = -1, var index = -1,
length = array ? array.length : 0, length = array ? array.length : 0,
resIndex = -1, resIndex = 0,
result = []; result = [];
while (++index < length) { while (++index < length) {
var value = array[index]; var value = array[index];
if (value) { if (value) {
result[++resIndex] = value; result[resIndex++] = value;
} }
} }
return result; return result;

View File

@@ -6,7 +6,8 @@ import rest from './rest';
/** /**
* Creates an array of unique `array` values not included in the other * Creates an array of unique `array` values not included in the other
* given arrays using [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero) * given arrays using [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero)
* for equality comparisons. * for equality comparisons. The order of result values is determined by the
* order they occur in the first array.
* *
* @static * @static
* @memberOf _ * @memberOf _

View File

@@ -8,7 +8,8 @@ import rest from './rest';
/** /**
* This method is like `_.difference` except that it accepts `iteratee` which * This method is like `_.difference` except that it accepts `iteratee` which
* is invoked for each element of `array` and `values` to generate the criterion * is invoked for each element of `array` and `values` to generate the criterion
* by which uniqueness is computed. The iteratee is invoked with one argument: (value). * by which they're compared. Result values are chosen from the first array.
* The iteratee is invoked with one argument: (value).
* *
* @static * @static
* @memberOf _ * @memberOf _

View File

@@ -6,8 +6,9 @@ import rest from './rest';
/** /**
* This method is like `_.difference` except that it accepts `comparator` * This method is like `_.difference` except that it accepts `comparator`
* which is invoked to compare elements of `array` to `values`. The comparator * which is invoked to compare elements of `array` to `values`. Result values
* is invoked with two arguments: (arrVal, othVal). * are chosen from the first array. The comparator is invoked with two arguments:
* (arrVal, othVal).
* *
* @static * @static
* @memberOf _ * @memberOf _

View File

@@ -6,13 +6,14 @@ import rest from './rest';
/** /**
* Creates an array of unique values that are included in all given arrays * Creates an array of unique values that are included in all given arrays
* using [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero) * using [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero)
* for equality comparisons. * for equality comparisons. The order of result values is determined by the
* order they occur in the first array.
* *
* @static * @static
* @memberOf _ * @memberOf _
* @category Array * @category Array
* @param {...Array} [arrays] The arrays to inspect. * @param {...Array} [arrays] The arrays to inspect.
* @returns {Array} Returns the new array of shared values. * @returns {Array} Returns the new array of intersecting values.
* @example * @example
* *
* _.intersection([2, 1], [4, 2], [1, 2]); * _.intersection([2, 1], [4, 2], [1, 2]);

View File

@@ -8,14 +8,15 @@ import rest from './rest';
/** /**
* This method is like `_.intersection` except that it accepts `iteratee` * This method is like `_.intersection` except that it accepts `iteratee`
* which is invoked for each element of each `arrays` to generate the criterion * which is invoked for each element of each `arrays` to generate the criterion
* by which uniqueness is computed. The iteratee is invoked with one argument: (value). * by which they're compared. Result values are chosen from the first array.
* The iteratee is invoked with one argument: (value).
* *
* @static * @static
* @memberOf _ * @memberOf _
* @category Array * @category Array
* @param {...Array} [arrays] The arrays to inspect. * @param {...Array} [arrays] The arrays to inspect.
* @param {Function|Object|string} [iteratee=_.identity] The iteratee invoked per element. * @param {Function|Object|string} [iteratee=_.identity] The iteratee invoked per element.
* @returns {Array} Returns the new array of shared values. * @returns {Array} Returns the new array of intersecting values.
* @example * @example
* *
* _.intersectionBy([2.1, 1.2], [4.3, 2.4], Math.floor); * _.intersectionBy([2.1, 1.2], [4.3, 2.4], Math.floor);

View File

@@ -6,15 +6,16 @@ import rest from './rest';
/** /**
* This method is like `_.intersection` except that it accepts `comparator` * This method is like `_.intersection` except that it accepts `comparator`
* which is invoked to compare elements of `arrays`. The comparator is invoked * which is invoked to compare elements of `arrays`. Result values are chosen
* with two arguments: (arrVal, othVal). * from the first array. The comparator is invoked with two arguments:
* (arrVal, othVal).
* *
* @static * @static
* @memberOf _ * @memberOf _
* @category Array * @category Array
* @param {...Array} [arrays] The arrays to inspect. * @param {...Array} [arrays] The arrays to inspect.
* @param {Function} [comparator] The comparator invoked per element. * @param {Function} [comparator] The comparator invoked per element.
* @returns {Array} Returns the new array of shared values. * @returns {Array} Returns the new array of intersecting values.
* @example * @example
* *
* var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]; * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];

View File

@@ -27,8 +27,7 @@ import isLength from './isLength';
* // => false * // => false
*/ */
function isArrayLike(value) { function isArrayLike(value) {
return value != null && return value != null && isLength(getLength(value)) && !isFunction(value);
!(typeof value == 'function' && isFunction(value)) && isLength(getLength(value));
} }
export default isArrayLike; export default isArrayLike;

View File

@@ -11,14 +11,14 @@ var objectProto = Object.prototype;
var hasOwnProperty = objectProto.hasOwnProperty; var hasOwnProperty = objectProto.hasOwnProperty;
/** /**
* Checks if `value` is empty. A value is considered empty unless it's an * Checks if `value` is an empty collection or object. A value is considered
* `arguments` object, array, string, or jQuery-like collection with a length * empty if it's an `arguments` object, array, string, or jQuery-like collection
* greater than `0` or an object with own enumerable properties. * with a length of `0` or has no own enumerable properties.
* *
* @static * @static
* @memberOf _ * @memberOf _
* @category Lang * @category Lang
* @param {Array|Object|string} value The value to inspect. * @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is empty, else `false`. * @returns {boolean} Returns `true` if `value` is empty, else `false`.
* @example * @example
* *

View File

@@ -33,9 +33,8 @@ function isError(value) {
if (!isObjectLike(value)) { if (!isObjectLike(value)) {
return false; return false;
} }
var Ctor = value.constructor;
return (objectToString.call(value) == errorTag) || return (objectToString.call(value) == errorTag) ||
(typeof Ctor == 'function' && objectToString.call(Ctor.prototype) == errorTag); (typeof value.message == 'string' && typeof value.name == 'string');
} }
export default isError; export default isError;

View File

@@ -31,8 +31,8 @@ var objectToString = objectProto.toString;
*/ */
function isFunction(value) { function isFunction(value) {
// The use of `Object#toString` avoids issues with the `typeof` operator // The use of `Object#toString` avoids issues with the `typeof` operator
// in Safari 8 which returns 'object' for typed array constructors, and // in Safari 8 which returns 'object' for typed array and weak map constructors,
// PhantomJS 1.9 which returns 'function' for `NodeList` instances. // and PhantomJS 1.9 which returns 'function' for `NodeList` instances.
var tag = isObject(value) ? objectToString.call(value) : ''; var tag = isObject(value) ? objectToString.call(value) : '';
return tag == funcTag || tag == genTag; return tag == funcTag || tag == genTag;
} }

View File

@@ -54,10 +54,7 @@ function isPlainObject(value) {
objectToString.call(value) != objectTag || isHostObject(value)) { objectToString.call(value) != objectTag || isHostObject(value)) {
return false; return false;
} }
var proto = objectProto; var proto = getPrototypeOf(value);
if (typeof value.constructor == 'function') {
proto = getPrototypeOf(value);
}
if (proto === null) { if (proto === null) {
return true; return true;
} }

View File

@@ -1,6 +1,6 @@
/** /**
* @license * @license
* lodash 4.5.0 (Custom Build) <https://lodash.com/> * lodash 4.6.0 (Custom Build) <https://lodash.com/>
* Build: `lodash modularize exports="es" -o ./` * Build: `lodash modularize exports="es" -o ./`
* Copyright 2012-2016 The Dojo Foundation <http://dojofoundation.org/> * Copyright 2012-2016 The Dojo Foundation <http://dojofoundation.org/>
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE> * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
@@ -44,7 +44,7 @@ import toInteger from './toInteger';
import lodash from './wrapperLodash'; import lodash from './wrapperLodash';
/** Used as the semantic version number. */ /** Used as the semantic version number. */
var VERSION = '4.5.0'; var VERSION = '4.6.0';
/** Used to compose bitmasks for wrapper metadata. */ /** Used to compose bitmasks for wrapper metadata. */
var BIND_KEY_FLAG = 2; var BIND_KEY_FLAG = 2;
@@ -179,6 +179,7 @@ lodash.propertyOf = util.propertyOf;
lodash.pull = array.pull; lodash.pull = array.pull;
lodash.pullAll = array.pullAll; lodash.pullAll = array.pullAll;
lodash.pullAllBy = array.pullAllBy; lodash.pullAllBy = array.pullAllBy;
lodash.pullAllWith = array.pullAllWith;
lodash.pullAt = array.pullAt; lodash.pullAt = array.pullAt;
lodash.range = util.range; lodash.range = util.range;
lodash.rangeRight = util.rangeRight; lodash.rangeRight = util.rangeRight;
@@ -221,6 +222,8 @@ lodash.uniqWith = array.uniqWith;
lodash.unset = object.unset; lodash.unset = object.unset;
lodash.unzip = array.unzip; lodash.unzip = array.unzip;
lodash.unzipWith = array.unzipWith; lodash.unzipWith = array.unzipWith;
lodash.update = object.update;
lodash.updateWith = object.updateWith;
lodash.values = object.values; lodash.values = object.values;
lodash.valuesIn = object.valuesIn; lodash.valuesIn = object.valuesIn;
lodash.without = array.without; lodash.without = array.without;

View File

@@ -1,6 +1,6 @@
/** /**
* @license * @license
* lodash 4.5.0 (Custom Build) <https://lodash.com/> * lodash 4.6.0 (Custom Build) <https://lodash.com/>
* Build: `lodash modularize exports="es" -o ./` * Build: `lodash modularize exports="es" -o ./`
* Copyright 2012-2016 The Dojo Foundation <http://dojofoundation.org/> * Copyright 2012-2016 The Dojo Foundation <http://dojofoundation.org/>
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE> * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
@@ -201,6 +201,7 @@ export { default as propertyOf } from './propertyOf';
export { default as pull } from './pull'; export { default as pull } from './pull';
export { default as pullAll } from './pullAll'; export { default as pullAll } from './pullAll';
export { default as pullAllBy } from './pullAllBy'; export { default as pullAllBy } from './pullAllBy';
export { default as pullAllWith } from './pullAllWith';
export { default as pullAt } from './pullAt'; export { default as pullAt } from './pullAt';
export { default as random } from './random'; export { default as random } from './random';
export { default as range } from './range'; export { default as range } from './range';
@@ -283,6 +284,8 @@ export { default as uniqueId } from './uniqueId';
export { default as unset } from './unset'; export { default as unset } from './unset';
export { default as unzip } from './unzip'; export { default as unzip } from './unzip';
export { default as unzipWith } from './unzipWith'; export { default as unzipWith } from './unzipWith';
export { default as update } from './update';
export { default as updateWith } from './updateWith';
export { default as upperCase } from './upperCase'; export { default as upperCase } from './upperCase';
export { default as upperFirst } from './upperFirst'; export { default as upperFirst } from './upperFirst';
export { default as value } from './value'; export { default as value } from './value';

View File

@@ -4,7 +4,8 @@ import baseIteratee from './_baseIteratee';
/** /**
* The opposite of `_.mapValues`; this method creates an object with the * The opposite of `_.mapValues`; this method creates an object with the
* same values as `object` and keys generated by running each own enumerable * same values as `object` and keys generated by running each own enumerable
* property of `object` through `iteratee`. * property of `object` through `iteratee`. The iteratee is invoked with
* three arguments: (value, key, object).
* *
* @static * @static
* @memberOf _ * @memberOf _

View File

@@ -4,7 +4,7 @@ import baseIteratee from './_baseIteratee';
/** /**
* Creates an object with the same keys as `object` and values generated by * Creates an object with the same keys as `object` and values generated by
* running each own enumerable property of `object` through `iteratee`. The * running each own enumerable property of `object` through `iteratee`. The
* iteratee function is invoked with three arguments: (value, key, object). * iteratee is invoked with three arguments: (value, key, object).
* *
* @static * @static
* @memberOf _ * @memberOf _

View File

@@ -2,12 +2,13 @@ import baseMerge from './_baseMerge';
import createAssigner from './_createAssigner'; import createAssigner from './_createAssigner';
/** /**
* Recursively merges own and inherited enumerable properties of source objects * This method is like `_.assign` except that it recursively merges own and
* into the destination object. Source properties that resolve to `undefined` * inherited enumerable properties of source objects into the destination
* are skipped if a destination value exists. Array and plain object properties * object. Source properties that resolve to `undefined` are skipped if a
* are merged recursively. Other objects and value types are overridden by * destination value exists. Array and plain object properties are merged
* assignment. Source objects are applied from left to right. Subsequent * recursively.Other objects and value types are overridden by assignment.
* sources overwrite property assignments of previous sources. * Source objects are applied from left to right. Subsequent sources
* overwrite property assignments of previous sources.
* *
* **Note:** This method mutates `object`. * **Note:** This method mutates `object`.
* *

View File

@@ -38,6 +38,8 @@ import toPairs from './toPairs';
import toPairsIn from './toPairsIn'; import toPairsIn from './toPairsIn';
import transform from './transform'; import transform from './transform';
import unset from './unset'; import unset from './unset';
import update from './update';
import updateWith from './updateWith';
import values from './values'; import values from './values';
import valuesIn from './valuesIn'; import valuesIn from './valuesIn';
@@ -50,5 +52,5 @@ export default {
mapKeys, mapValues, merge, mergeWith, omit, mapKeys, mapValues, merge, mergeWith, omit,
omitBy, pick, pickBy, result, set, omitBy, pick, pickBy, result, set,
setWith, toPairs, toPairsIn, transform, unset, setWith, toPairs, toPairsIn, transform, unset,
values, valuesIn update, updateWith, values, valuesIn
}; };

View File

@@ -38,6 +38,8 @@ export { default as toPairs } from './toPairs';
export { default as toPairsIn } from './toPairsIn'; export { default as toPairsIn } from './toPairsIn';
export { default as transform } from './transform'; export { default as transform } from './transform';
export { default as unset } from './unset'; export { default as unset } from './unset';
export { default as update } from './update';
export { default as updateWith } from './updateWith';
export { default as values } from './values'; export { default as values } from './values';
export { default as valuesIn } from './valuesIn'; export { default as valuesIn } from './valuesIn';
export { default as default } from './object.default'; export { default as default } from './object.default';

View File

@@ -2,9 +2,10 @@ import baseIteratee from './_baseIteratee';
import basePickBy from './_basePickBy'; import basePickBy from './_basePickBy';
/** /**
* The opposite of `_.pickBy`; this method creates an object composed of the * The opposite of `_.pickBy`; this method creates an object composed of
* own and inherited enumerable properties of `object` that `predicate` * the own and inherited enumerable properties of `object` that `predicate`
* doesn't return truthy for. * doesn't return truthy for. The predicate is invoked with two arguments:
* (value, key).
* *
* @static * @static
* @memberOf _ * @memberOf _
@@ -20,7 +21,7 @@ import basePickBy from './_basePickBy';
* // => { 'b': '2' } * // => { 'b': '2' }
*/ */
function omitBy(object, predicate) { function omitBy(object, predicate) {
predicate = baseIteratee(predicate, 2); predicate = baseIteratee(predicate);
return basePickBy(object, function(value, key) { return basePickBy(object, function(value, key) {
return !predicate(value, key); return !predicate(value, key);
}); });

View File

@@ -1,6 +1,6 @@
{ {
"name": "lodash-es", "name": "lodash-es",
"version": "4.5.0", "version": "4.6.0",
"description": "Lodash exported as ES modules.", "description": "Lodash exported as ES modules.",
"homepage": "https://lodash.com/custom-builds", "homepage": "https://lodash.com/custom-builds",
"license": "MIT", "license": "MIT",

View File

@@ -1,4 +1,5 @@
import createWrapper from './_createWrapper'; import createWrapper from './_createWrapper';
import getPlaceholder from './_getPlaceholder';
import replaceHolders from './_replaceHolders'; import replaceHolders from './_replaceHolders';
import rest from './rest'; import rest from './rest';
@@ -38,9 +39,7 @@ var PARTIAL_FLAG = 32;
* // => 'hi fred' * // => 'hi fred'
*/ */
var partial = rest(function(func, partials) { var partial = rest(function(func, partials) {
var placeholder = partial.placeholder, var holders = replaceHolders(partials, getPlaceholder(partial));
holders = replaceHolders(partials, placeholder);
return createWrapper(func, PARTIAL_FLAG, undefined, partials, holders); return createWrapper(func, PARTIAL_FLAG, undefined, partials, holders);
}); });

View File

@@ -1,4 +1,5 @@
import createWrapper from './_createWrapper'; import createWrapper from './_createWrapper';
import getPlaceholder from './_getPlaceholder';
import replaceHolders from './_replaceHolders'; import replaceHolders from './_replaceHolders';
import rest from './rest'; import rest from './rest';
@@ -37,9 +38,7 @@ var PARTIAL_RIGHT_FLAG = 64;
* // => 'hello fred' * // => 'hello fred'
*/ */
var partialRight = rest(function(func, partials) { var partialRight = rest(function(func, partials) {
var placeholder = partialRight.placeholder, var holders = replaceHolders(partials, getPlaceholder(partialRight));
holders = replaceHolders(partials, placeholder);
return createWrapper(func, PARTIAL_RIGHT_FLAG, undefined, partials, holders); return createWrapper(func, PARTIAL_RIGHT_FLAG, undefined, partials, holders);
}); });

View File

@@ -19,7 +19,7 @@ import basePickBy from './_basePickBy';
* // => { 'a': 1, 'c': 3 } * // => { 'a': 1, 'c': 3 }
*/ */
function pickBy(object, predicate) { function pickBy(object, predicate) {
return object == null ? {} : basePickBy(object, baseIteratee(predicate, 2)); return object == null ? {} : basePickBy(object, baseIteratee(predicate));
} }
export default pickBy; export default pickBy;

View File

@@ -6,7 +6,8 @@ import rest from './rest';
* [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero) * [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero)
* for equality comparisons. * for equality comparisons.
* *
* **Note:** Unlike `_.without`, this method mutates `array`. * **Note:** Unlike `_.without`, this method mutates `array`. Use `_.remove`
* to remove elements from an array by predicate.
* *
* @static * @static
* @memberOf _ * @memberOf _

View File

@@ -1,10 +1,10 @@
import baseIteratee from './_baseIteratee'; import baseIteratee from './_baseIteratee';
import basePullAllBy from './_basePullAllBy'; import basePullAll from './_basePullAll';
/** /**
* This method is like `_.pullAll` except that it accepts `iteratee` which is * This method is like `_.pullAll` except that it accepts `iteratee` which is
* invoked for each element of `array` and `values` to generate the criterion * invoked for each element of `array` and `values` to generate the criterion
* by which uniqueness is computed. The iteratee is invoked with one argument: (value). * by which they're compared. The iteratee is invoked with one argument: (value).
* *
* **Note:** Unlike `_.differenceBy`, this method mutates `array`. * **Note:** Unlike `_.differenceBy`, this method mutates `array`.
* *
@@ -25,7 +25,7 @@ import basePullAllBy from './_basePullAllBy';
*/ */
function pullAllBy(array, values, iteratee) { function pullAllBy(array, values, iteratee) {
return (array && array.length && values && values.length) return (array && array.length && values && values.length)
? basePullAllBy(array, values, baseIteratee(iteratee)) ? basePullAll(array, values, baseIteratee(iteratee))
: array; : array;
} }

31
pullAllWith.js Normal file
View File

@@ -0,0 +1,31 @@
import basePullAll from './_basePullAll';
/**
* This method is like `_.pullAll` except that it accepts `comparator` which
* is invoked to compare elements of `array` to `values`. The comparator is
* invoked with two arguments: (arrVal, othVal).
*
* **Note:** Unlike `_.differenceWith`, this method mutates `array`.
*
* @static
* @memberOf _
* @category Array
* @param {Array} array The array to modify.
* @param {Array} values The values to remove.
* @param {Function} [comparator] The comparator invoked per element.
* @returns {Array} Returns `array`.
* @example
*
* var array = [{ 'x': 1, 'y': 2 }, { 'x': 3, 'y': 4 }, { 'x': 5, 'y': 6 }];
*
* _.pullAllWith(array, [{ 'x': 3, 'y': 4 }], _.isEqual);
* console.log(array);
* // => [{ 'x': 1, 'y': 2 }, { 'x': 5, 'y': 6 }]
*/
function pullAllWith(array, values, comparator) {
return (array && array.length && values && values.length)
? basePullAll(array, values, undefined, comparator)
: array;
}
export default pullAllWith;

View File

@@ -3,10 +3,11 @@ import basePullAt from './_basePullAt';
/** /**
* Removes all elements from `array` that `predicate` returns truthy for * Removes all elements from `array` that `predicate` returns truthy for
* and returns an array of the removed elements. The predicate is invoked with * and returns an array of the removed elements. The predicate is invoked
* three arguments: (value, index, array). * with three arguments: (value, index, array).
* *
* **Note:** Unlike `_.filter`, this method mutates `array`. * **Note:** Unlike `_.filter`, this method mutates `array`. Use `_.pull`
* to pull elements from an array by value.
* *
* @static * @static
* @memberOf _ * @memberOf _

View File

@@ -18,8 +18,10 @@ import baseSet from './_baseSet';
* @returns {Object} Returns `object`. * @returns {Object} Returns `object`.
* @example * @example
* *
* _.setWith({ '0': { 'length': 2 } }, '[0][1][2]', 3, Object); * var object = {};
* // => { '0': { '1': { '2': 3 }, 'length': 2 } } *
* _.setWith(object, '[0][1]', 'a', Object);
* // => { '0': { '1': 'a' } }
*/ */
function setWith(object, path, value, customizer) { function setWith(object, path, value, customizer) {
customizer = typeof customizer == 'function' ? customizer : undefined; customizer = typeof customizer == 'function' ? customizer : undefined;

View File

@@ -12,8 +12,8 @@ var MAX_ARRAY_LENGTH = 4294967295;
var nativeMin = Math.min; var nativeMin = Math.min;
/** /**
* Invokes the iteratee function `n` times, returning an array of the results * Invokes the iteratee `n` times, returning an array of the results of
* of each invocation. The iteratee is invoked with one argument; (index). * each invocation. The iteratee is invoked with one argument; (index).
* *
* @static * @static
* @memberOf _ * @memberOf _

View File

@@ -1,7 +1,8 @@
import toString from './toString'; import toString from './toString';
/** /**
* Converts `string`, as a whole, to lower case. * Converts `string`, as a whole, to lower case just like
* [String#toLowerCase](https://mdn.io/toLowerCase).
* *
* @static * @static
* @memberOf _ * @memberOf _

View File

@@ -6,7 +6,7 @@ var INFINITY = 1 / 0;
/** Used to convert symbols to primitives and strings. */ /** Used to convert symbols to primitives and strings. */
var symbolProto = Symbol ? Symbol.prototype : undefined, var symbolProto = Symbol ? Symbol.prototype : undefined,
symbolToString = Symbol ? symbolProto.toString : undefined; symbolToString = symbolProto ? symbolProto.toString : undefined;
/** /**
* Converts `value` to a string if it's not one. An empty string is returned * Converts `value` to a string if it's not one. An empty string is returned
@@ -37,7 +37,7 @@ function toString(value) {
return ''; return '';
} }
if (isSymbol(value)) { if (isSymbol(value)) {
return Symbol ? symbolToString.call(value) : ''; return symbolToString ? symbolToString.call(value) : '';
} }
var result = (value + ''); var result = (value + '');
return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result; return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;

View File

@@ -1,7 +1,8 @@
import toString from './toString'; import toString from './toString';
/** /**
* Converts `string`, as a whole, to upper case. * Converts `string`, as a whole, to upper case just like
* [String#toUpperCase](https://mdn.io/toUpperCase).
* *
* @static * @static
* @memberOf _ * @memberOf _

View File

@@ -7,6 +7,9 @@ import isFunction from './isFunction';
import isObject from './isObject'; import isObject from './isObject';
import isTypedArray from './isTypedArray'; import isTypedArray from './isTypedArray';
/** Built-in value references. */
var getPrototypeOf = Object.getPrototypeOf;
/** /**
* An alternative to `_.reduce`; this method transforms `object` to a new * An alternative to `_.reduce`; this method transforms `object` to a new
* `accumulator` object which is the result of running each of its own enumerable * `accumulator` object which is the result of running each of its own enumerable
@@ -45,7 +48,7 @@ function transform(object, iteratee, accumulator) {
if (isArr) { if (isArr) {
accumulator = isArray(object) ? new Ctor : []; accumulator = isArray(object) ? new Ctor : [];
} else { } else {
accumulator = baseCreate(isFunction(Ctor) ? Ctor.prototype : undefined); accumulator = isFunction(Ctor) ? baseCreate(getPrototypeOf(object)) : {};
} }
} else { } else {
accumulator = {}; accumulator = {};

34
update.js Normal file
View File

@@ -0,0 +1,34 @@
import baseCastFunction from './_baseCastFunction';
import baseUpdate from './_baseUpdate';
/**
* This method is like `_.set` except that accepts `updater` to produce the
* value to set. Use `_.updateWith` to customize `path` creation. The `updater`
* is invoked with one argument: (value).
*
* **Note:** This method mutates `object`.
*
* @static
* @memberOf _
* @category Object
* @param {Object} object The object to modify.
* @param {Array|string} path The path of the property to set.
* @param {Function} updater The function to produce the updated value.
* @returns {Object} Returns `object`.
* @example
*
* var object = { 'a': [{ 'b': { 'c': 3 } }] };
*
* _.update(object, 'a[0].b.c', function(n) { return n * n; });
* console.log(object.a[0].b.c);
* // => 9
*
* _.update(object, 'x[0].y.z', function(n) { return n ? n + 1 : 0; });
* console.log(object.x[0].y.z);
* // => 0
*/
function update(object, path, updater) {
return object == null ? object : baseUpdate(object, path, baseCastFunction(updater));
}
export default update;

32
updateWith.js Normal file
View File

@@ -0,0 +1,32 @@
import baseCastFunction from './_baseCastFunction';
import baseUpdate from './_baseUpdate';
/**
* This method is like `_.update` except that it accepts `customizer` which is
* invoked to produce the objects of `path`. If `customizer` returns `undefined`
* path creation is handled by the method instead. The `customizer` is invoked
* with three arguments: (nsValue, key, nsObject).
*
* **Note:** This method mutates `object`.
*
* @static
* @memberOf _
* @category Object
* @param {Object} object The object to modify.
* @param {Array|string} path The path of the property to set.
* @param {Function} updater The function to produce the updated value.
* @param {Function} [customizer] The function to customize assigned values.
* @returns {Object} Returns `object`.
* @example
*
* var object = {};
*
* _.updateWith(object, '[0][1]', _.constant('a'), Object);
* // => { '0': { '1': 'a' } }
*/
function updateWith(object, path, updater, customizer) {
customizer = typeof customizer == 'function' ? customizer : undefined;
return object == null ? object : baseUpdate(object, path, baseCastFunction(updater), customizer);
}
export default updateWith;

View File

@@ -53,46 +53,48 @@ var hasOwnProperty = objectProto.hasOwnProperty;
* `after`, `ary`, `assign`, `assignIn`, `assignInWith`, `assignWith`, `at`, * `after`, `ary`, `assign`, `assignIn`, `assignInWith`, `assignWith`, `at`,
* `before`, `bind`, `bindAll`, `bindKey`, `castArray`, `chain`, `chunk`, * `before`, `bind`, `bindAll`, `bindKey`, `castArray`, `chain`, `chunk`,
* `commit`, `compact`, `concat`, `conforms`, `constant`, `countBy`, `create`, * `commit`, `compact`, `concat`, `conforms`, `constant`, `countBy`, `create`,
* `curry`, `debounce`, `defaults`, `defaultsDeep`, `defer`, `delay`, `difference`, * `curry`, `debounce`, `defaults`, `defaultsDeep`, `defer`, `delay`,
* `differenceBy`, `differenceWith`, `drop`, `dropRight`, `dropRightWhile`, * `difference`, `differenceBy`, `differenceWith`, `drop`, `dropRight`,
* `dropWhile`, `fill`, `filter`, `flatten`, `flattenDeep`, `flattenDepth`, * `dropRightWhile`, `dropWhile`, `extend`, `extendWith`, `fill`, `filter`,
* `flip`, `flow`, `flowRight`, `fromPairs`, `functions`, `functionsIn`, * `flatten`, `flattenDeep`, `flattenDepth`, `flip`, `flow`, `flowRight`,
* `groupBy`, `initial`, `intersection`, `intersectionBy`, `intersectionWith`, * `fromPairs`, `functions`, `functionsIn`, `groupBy`, `initial`, `intersection`,
* `invert`, `invertBy`, `invokeMap`, `iteratee`, `keyBy`, `keys`, `keysIn`, * `intersectionBy`, `intersectionWith`, `invert`, `invertBy`, `invokeMap`,
* `map`, `mapKeys`, `mapValues`, `matches`, `matchesProperty`, `memoize`, * `iteratee`, `keyBy`, `keys`, `keysIn`, `map`, `mapKeys`, `mapValues`,
* `merge`, `mergeWith`, `method`, `methodOf`, `mixin`, `negate`, `nthArg`, * `matches`, `matchesProperty`, `memoize`, `merge`, `mergeWith`, `method`,
* `omit`, `omitBy`, `once`, `orderBy`, `over`, `overArgs`, `overEvery`, * `methodOf`, `mixin`, `negate`, `nthArg`, `omit`, `omitBy`, `once`, `orderBy`,
* `overSome`, `partial`, `partialRight`, `partition`, `pick`, `pickBy`, `plant`, * `over`, `overArgs`, `overEvery`, `overSome`, `partial`, `partialRight`,
* `property`, `propertyOf`, `pull`, `pullAll`, `pullAllBy`, `pullAt`, `push`, * `partition`, `pick`, `pickBy`, `plant`, `property`, `propertyOf`, `pull`,
* `range`, `rangeRight`, `rearg`, `reject`, `remove`, `rest`, `reverse`, * `pullAll`, `pullAllBy`, `pullAllWith`, `pullAt`, `push`, `range`,
* `sampleSize`, `set`, `setWith`, `shuffle`, `slice`, `sort`, `sortBy`, * `rangeRight`, `rearg`, `reject`, `remove`, `rest`, `reverse`, `sampleSize`,
* `splice`, `spread`, `tail`, `take`, `takeRight`, `takeRightWhile`, * `set`, `setWith`, `shuffle`, `slice`, `sort`, `sortBy`, `splice`, `spread`,
* `takeWhile`, `tap`, `throttle`, `thru`, `toArray`, `toPairs`, `toPairsIn`, * `tail`, `take`, `takeRight`, `takeRightWhile`, `takeWhile`, `tap`, `throttle`,
* `toPath`, `toPlainObject`, `transform`, `unary`, `union`, `unionBy`, * `thru`, `toArray`, `toPairs`, `toPairsIn`, `toPath`, `toPlainObject`,
* `unionWith`, `uniq`, `uniqBy`, `uniqWith`, `unset`, `unshift`, `unzip`, * `transform`, `unary`, `union`, `unionBy`, `unionWith`, `uniq`, `uniqBy`,
* `unzipWith`, `values`, `valuesIn`, `without`, `wrap`, `xor`, `xorBy`, * `uniqWith`, `unset`, `unshift`, `unzip`, `unzipWith`, `update`, `values`,
* `xorWith`, `zip`, `zipObject`, `zipObjectDeep`, and `zipWith` * `valuesIn`, `without`, `wrap`, `xor`, `xorBy`, `xorWith`, `zip`, `zipObject`,
* `zipObjectDeep`, and `zipWith`
* *
* The wrapper methods that are **not** chainable by default are: * The wrapper methods that are **not** chainable by default are:
* `add`, `attempt`, `camelCase`, `capitalize`, `ceil`, `clamp`, `clone`, * `add`, `attempt`, `camelCase`, `capitalize`, `ceil`, `clamp`, `clone`,
* `cloneDeep`, `cloneDeepWith`, `cloneWith`, `deburr`, `endsWith`, `eq`, * `cloneDeep`, `cloneDeepWith`, `cloneWith`, `deburr`, `each`, `eachRight`,
* `escape`, `escapeRegExp`, `every`, `find`, `findIndex`, `findKey`, `findLast`, * `endsWith`, `eq`, `escape`, `escapeRegExp`, `every`, `find`, `findIndex`,
* `findLastIndex`, `findLastKey`, `floor`, `forEach`, `forEachRight`, `forIn`, * `findKey`, `findLast`, `findLastIndex`, `findLastKey`, `first`, `floor`,
* `forInRight`, `forOwn`, `forOwnRight`, `get`, `gt`, `gte`, `has`, `hasIn`, * `forEach`, `forEachRight`, `forIn`, `forInRight`, `forOwn`, `forOwnRight`,
* `head`, `identity`, `includes`, `indexOf`, `inRange`, `invoke`, `isArguments`, * `get`, `gt`, `gte`, `has`, `hasIn`, `head`, `identity`, `includes`,
* `isArray`, `isArrayBuffer`, `isArrayLike`, `isArrayLikeObject`, `isBoolean`, * `indexOf`, `inRange`, `invoke`, `isArguments`, `isArray`, `isArrayBuffer`,
* `isBuffer`, `isDate`, `isElement`, `isEmpty`, `isEqual`, `isEqualWith`, * `isArrayLike`, `isArrayLikeObject`, `isBoolean`, `isBuffer`, `isDate`,
* `isError`, `isFinite`, `isFunction`, `isInteger`, `isLength`, `isMap`, * `isElement`, `isEmpty`, `isEqual`, `isEqualWith`, `isError`, `isFinite`,
* `isMatch`, `isMatchWith`, `isNaN`, `isNative`, `isNil`, `isNull`, `isNumber`, * `isFunction`, `isInteger`, `isLength`, `isMap`, `isMatch`, `isMatchWith`,
* `isObject`, `isObjectLike`, `isPlainObject`, `isRegExp`, `isSafeInteger`, * `isNaN`, `isNative`, `isNil`, `isNull`, `isNumber`, `isObject`, `isObjectLike`,
* `isSet`, `isString`, `isUndefined`, `isTypedArray`, `isWeakMap`, `isWeakSet`, * `isPlainObject`, `isRegExp`, `isSafeInteger`, `isSet`, `isString`,
* `join`, `kebabCase`, `last`, `lastIndexOf`, `lowerCase`, `lowerFirst`, * `isUndefined`, `isTypedArray`, `isWeakMap`, `isWeakSet`, `join`, `kebabCase`,
* `lt`, `lte`, `max`, `maxBy`, `mean`, `min`, `minBy`, `noConflict`, `noop`, * `last`, `lastIndexOf`, `lowerCase`, `lowerFirst`, `lt`, `lte`, `max`,
* `now`, `pad`, `padEnd`, `padStart`, `parseInt`, `pop`, `random`, `reduce`, * `maxBy`, `mean`, `min`, `minBy`, `noConflict`, `noop`, `now`, `pad`,
* `reduceRight`, `repeat`, `result`, `round`, `runInContext`, `sample`, * `padEnd`, `padStart`, `parseInt`, `pop`, `random`, `reduce`, `reduceRight`,
* `shift`, `size`, `snakeCase`, `some`, `sortedIndex`, `sortedIndexBy`, * `repeat`, `result`, `round`, `runInContext`, `sample`, `shift`, `size`,
* `sortedLastIndex`, `sortedLastIndexBy`, `startCase`, `startsWith`, `subtract`, * `snakeCase`, `some`, `sortedIndex`, `sortedIndexBy`, `sortedLastIndex`,
* `sum`, `sumBy`, `template`, `times`, `toLower`, `toInteger`, `toLength`, * `sortedLastIndexBy`, `startCase`, `startsWith`, `subtract`, `sum`, `sumBy`,
* `template`, `times`, `toInteger`, `toJSON`, `toLength`, `toLower`,
* `toNumber`, `toSafeInteger`, `toString`, `toUpper`, `trim`, `trimEnd`, * `toNumber`, `toSafeInteger`, `toString`, `toUpper`, `trim`, `trimEnd`,
* `trimStart`, `truncate`, `unescape`, `uniqueId`, `upperCase`, `upperFirst`, * `trimStart`, `truncate`, `unescape`, `uniqueId`, `upperCase`, `upperFirst`,
* `value`, and `words` * `value`, and `words`
@@ -137,5 +139,6 @@ function lodash(value) {
// Ensure wrappers are instances of `baseLodash`. // Ensure wrappers are instances of `baseLodash`.
lodash.prototype = baseLodash.prototype; lodash.prototype = baseLodash.prototype;
lodash.prototype.constructor = lodash;
export default lodash; export default lodash;

3
xor.js
View File

@@ -5,7 +5,8 @@ import rest from './rest';
/** /**
* Creates an array of unique values that is the [symmetric difference](https://en.wikipedia.org/wiki/Symmetric_difference) * Creates an array of unique values that is the [symmetric difference](https://en.wikipedia.org/wiki/Symmetric_difference)
* of the given arrays. * of the given arrays. The order of result values is determined by the order
* they occur in the arrays.
* *
* @static * @static
* @memberOf _ * @memberOf _

View File

@@ -8,7 +8,7 @@ import rest from './rest';
/** /**
* This method is like `_.xor` except that it accepts `iteratee` which is * This method is like `_.xor` except that it accepts `iteratee` which is
* invoked for each element of each `arrays` to generate the criterion by which * invoked for each element of each `arrays` to generate the criterion by which
* uniqueness is computed. The iteratee is invoked with one argument: (value). * by which they're compared. The iteratee is invoked with one argument: (value).
* *
* @static * @static
* @memberOf _ * @memberOf _