Compare commits

...

4 Commits

Author SHA1 Message Date
John-David Dalton
764eccfdc0 Bump to v4.11.0. 2016-04-13 10:21:06 -07:00
John-David Dalton
f10bb8b80b Bump to v4.10.0. 2016-04-10 22:55:59 -07:00
John-David Dalton
b7e3b3febd Bump to v4.9.0. 2016-04-08 01:32:35 -07:00
John-David Dalton
e8cff1ef54 Bump to v4.8.2. 2016-04-04 13:55:37 -07:00
108 changed files with 435 additions and 293 deletions

View File

@@ -1,4 +1,4 @@
# lodash-es v4.8.0
# lodash-es v4.11.0
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 ./
```
See the [package source](https://github.com/lodash/lodash/tree/4.8.0-es) for more details.
See the [package source](https://github.com/lodash/lodash/tree/4.11.0-es) for more details.

View File

@@ -4,7 +4,7 @@ import nativeCreate from './_nativeCreate';
var objectProto = Object.prototype;
/**
* Creates an hash object.
* Creates a hash object.
*
* @private
* @constructor

View File

@@ -1,7 +1,5 @@
import arrayPush from './_arrayPush';
import isArguments from './isArguments';
import isArray from './isArray';
import isArrayLikeObject from './isArrayLikeObject';
import isFlattenable from './_isFlattenable';
/**
* The base implementation of `_.flatten` with support for restricting flattening.
@@ -9,23 +7,24 @@ import isArrayLikeObject from './isArrayLikeObject';
* @private
* @param {Array} array The array to flatten.
* @param {number} depth The maximum recursion depth.
* @param {boolean} [isStrict] Restrict flattening to arrays-like objects.
* @param {boolean} [predicate=isFlattenable] The function invoked per iteration.
* @param {boolean} [isStrict] Restrict to values that pass `predicate` checks.
* @param {Array} [result=[]] The initial result value.
* @returns {Array} Returns the new flattened array.
*/
function baseFlatten(array, depth, isStrict, result) {
result || (result = []);
function baseFlatten(array, depth, predicate, isStrict, result) {
var index = -1,
length = array.length;
predicate || (predicate = isFlattenable);
result || (result = []);
while (++index < length) {
var value = array[index];
if (depth > 0 && isArrayLikeObject(value) &&
(isStrict || isArray(value) || isArguments(value))) {
if (depth > 0 && predicate(value)) {
if (depth > 1) {
// Recursively flatten arrays (susceptible to call stack limits).
baseFlatten(value, depth - 1, isStrict, result);
baseFlatten(value, depth - 1, predicate, isStrict, result);
} else {
arrayPush(result, value);
}

View File

@@ -2,7 +2,7 @@ import createBaseFor from './_createBaseFor';
/**
* The base implementation of `baseForOwn` which iterates over `object`
* properties returned by `keysFunc` invoking `iteratee` for each property.
* properties returned by `keysFunc` and invokes `iteratee` for each property.
* Iteratee functions may exit iteration early by explicitly returning `false`.
*
* @private

View File

@@ -1,4 +1,4 @@
import baseCastPath from './_baseCastPath';
import castPath from './_castPath';
import isKey from './_isKey';
/**
@@ -10,7 +10,7 @@ import isKey from './_isKey';
* @returns {*} Returns the resolved value.
*/
function baseGet(object, path) {
path = isKey(path, object) ? [path] : baseCastPath(path);
path = isKey(path, object) ? [path] : castPath(path);
var index = 0,
length = path.length;

View File

@@ -1,5 +1,5 @@
import apply from './_apply';
import baseCastPath from './_baseCastPath';
import castPath from './_castPath';
import isKey from './_isKey';
import last from './last';
import parent from './_parent';
@@ -16,7 +16,7 @@ import parent from './_parent';
*/
function baseInvoke(object, path, args) {
if (!isKey(path, object)) {
path = baseCastPath(path);
path = castPath(path);
object = parent(object, path);
path = last(path);
}

20
_baseNth.js Normal file
View File

@@ -0,0 +1,20 @@
import isIndex from './_isIndex';
/**
* The base implementation of `_.nth` which doesn't coerce `n` to an integer.
*
* @private
* @param {Array} array The array to query.
* @param {number} n The index of the element to return.
* @returns {*} Returns the nth element of `array`.
*/
function baseNth(array, n) {
var length = array.length;
if (!length) {
return;
}
n += n < 0 ? length : 0;
return isIndex(n, length) ? array[n] : undefined;
}
export default baseNth;

View File

@@ -2,6 +2,7 @@ import arrayMap from './_arrayMap';
import baseIteratee from './_baseIteratee';
import baseMap from './_baseMap';
import baseSortBy from './_baseSortBy';
import baseUnary from './_baseUnary';
import compareMultiple from './_compareMultiple';
import identity from './identity';
@@ -16,7 +17,7 @@ import identity from './identity';
*/
function baseOrderBy(collection, iteratees, orders) {
var index = -1;
iteratees = arrayMap(iteratees.length ? iteratees : [identity], baseIteratee);
iteratees = arrayMap(iteratees.length ? iteratees : [identity], baseUnary(baseIteratee));
var result = baseMap(collection, function(value, key, collection) {
var criteria = arrayMap(iteratees, function(iteratee) {

View File

@@ -1,4 +1,4 @@
import baseCastPath from './_baseCastPath';
import castPath from './_castPath';
import isIndex from './_isIndex';
import isKey from './_isKey';
import last from './last';
@@ -31,7 +31,7 @@ function basePullAt(array, indexes) {
splice.call(array, index, 1);
}
else if (!isKey(index, array)) {
var path = baseCastPath(index),
var path = castPath(index),
object = parent(array, path);
if (object != null) {

View File

@@ -1,5 +1,5 @@
import assignValue from './_assignValue';
import baseCastPath from './_baseCastPath';
import castPath from './_castPath';
import isIndex from './_isIndex';
import isKey from './_isKey';
import isObject from './isObject';
@@ -15,7 +15,7 @@ import isObject from './isObject';
* @returns {Object} Returns `object`.
*/
function baseSet(object, path, value, customizer) {
path = isKey(path, object) ? [path] : baseCastPath(path);
path = isKey(path, object) ? [path] : castPath(path);
var index = -1,
length = path.length,

View File

@@ -1,4 +1,4 @@
import baseCastPath from './_baseCastPath';
import castPath from './_castPath';
import has from './has';
import isKey from './_isKey';
import last from './last';
@@ -13,7 +13,7 @@ import parent from './_parent';
* @returns {boolean} Returns `true` if the property is deleted, else `false`.
*/
function baseUnset(object, path) {
path = isKey(path, object) ? [path] : baseCastPath(path);
path = isKey(path, object) ? [path] : castPath(path);
object = parent(object, path);
var key = last(path);
return (object != null && has(object, key)) ? delete object[key] : true;

View File

@@ -7,8 +7,8 @@ import isArrayLikeObject from './isArrayLikeObject';
* @param {*} value The value to inspect.
* @returns {Array|Object} Returns the cast array-like object.
*/
function baseCastArrayLikeObject(value) {
function castArrayLikeObject(value) {
return isArrayLikeObject(value) ? value : [];
}
export default baseCastArrayLikeObject;
export default castArrayLikeObject;

View File

@@ -7,8 +7,8 @@ import identity from './identity';
* @param {*} value The value to inspect.
* @returns {Function} Returns cast function.
*/
function baseCastFunction(value) {
function castFunction(value) {
return typeof value == 'function' ? value : identity;
}
export default baseCastFunction;
export default castFunction;

View File

@@ -8,8 +8,8 @@ import stringToPath from './_stringToPath';
* @param {*} value The value to inspect.
* @returns {Array} Returns the cast property path array.
*/
function baseCastPath(value) {
function castPath(value) {
return isArray(value) ? value : stringToPath(value);
}
export default baseCastPath;
export default castPath;

18
_castSlice.js Normal file
View File

@@ -0,0 +1,18 @@
import baseSlice from './_baseSlice';
/**
* Casts `array` to a slice if it's needed.
*
* @private
* @param {Array} array The array to inspect.
* @param {number} start The start position.
* @param {number} [end=array.length] The end position.
* @returns {Array} Returns the cast slice.
*/
function castSlice(array, start, end) {
var length = array.length;
end = end === undefined ? length : end;
return (!start && end >= length) ? array : baseSlice(array, start, end);
}
export default castSlice;

View File

@@ -1,4 +1,4 @@
import copyObjectWith from './_copyObjectWith';
import assignValue from './_assignValue';
/**
* Copies properties of `source` to `object`.
@@ -7,10 +7,25 @@ import copyObjectWith from './_copyObjectWith';
* @param {Object} source The object to copy properties from.
* @param {Array} props The property identifiers to copy.
* @param {Object} [object={}] The object to copy properties to.
* @param {Function} [customizer] The function to customize copied values.
* @returns {Object} Returns `object`.
*/
function copyObject(source, props, object) {
return copyObjectWith(source, props, object);
function copyObject(source, props, object, customizer) {
object || (object = {});
var index = -1,
length = props.length;
while (++index < length) {
var key = props[index];
var newValue = customizer
? customizer(object[key], source[key], key, object, source)
: source[key];
assignValue(object, key, newValue);
}
return object;
}
export default copyObject;

View File

@@ -1,32 +0,0 @@
import assignValue from './_assignValue';
/**
* This function is like `copyObject` except that it accepts a function to
* customize copied values.
*
* @private
* @param {Object} source The object to copy properties from.
* @param {Array} props The property identifiers to copy.
* @param {Object} [object={}] The object to copy properties to.
* @param {Function} [customizer] The function to customize copied values.
* @returns {Object} Returns `object`.
*/
function copyObjectWith(source, props, object, customizer) {
object || (object = {});
var index = -1,
length = props.length;
while (++index < length) {
var key = props[index];
var newValue = customizer
? customizer(object[key], source[key], key, object, source)
: source[key];
assignValue(object, key, newValue);
}
return object;
}
export default copyObjectWith;

View File

@@ -1,18 +1,8 @@
import castSlice from './_castSlice';
import reHasComplexSymbol from './_reHasComplexSymbol';
import stringToArray from './_stringToArray';
import toString from './toString';
/** Used to compose unicode character classes. */
var rsAstralRange = '\\ud800-\\udfff',
rsComboMarksRange = '\\u0300-\\u036f\\ufe20-\\ufe23',
rsComboSymbolsRange = '\\u20d0-\\u20f0',
rsVarRange = '\\ufe0e\\ufe0f';
/** Used to compose unicode capture groups. */
var rsZWJ = '\\u200d';
/** Used to detect strings with [zero-width joiners or code points from the astral planes](http://eev.ee/blog/2015/09/12/dark-corners-of-unicode/). */
var reHasComplexSymbol = RegExp('[' + rsZWJ + rsAstralRange + rsComboMarksRange + rsComboSymbolsRange + rsVarRange + ']');
/**
* Creates a function like `_.lowerFirst`.
*
@@ -28,8 +18,13 @@ function createCaseFirst(methodName) {
? stringToArray(string)
: undefined;
var chr = strSymbols ? strSymbols[0] : string.charAt(0),
trailing = strSymbols ? strSymbols.slice(1).join('') : string.slice(1);
var chr = strSymbols
? strSymbols[0]
: string.charAt(0);
var trailing = strSymbols
? castSlice(strSymbols, 1).join('')
: string.slice(1);
return chr[methodName]() + trailing;
};

View File

@@ -2,6 +2,12 @@ import arrayReduce from './_arrayReduce';
import deburr from './deburr';
import words from './words';
/** Used to compose unicode capture groups. */
var rsApos = "['\u2019]";
/** Used to match apostrophes. */
var reApos = RegExp(rsApos, 'g');
/**
* Creates a function like `_.camelCase`.
*
@@ -11,7 +17,7 @@ import words from './words';
*/
function createCompounder(callback) {
return function(string) {
return arrayReduce(words(deburr(string)), callback, '');
return arrayReduce(words(deburr(string).replace(reApos, '')), callback, '');
};
}

View File

@@ -1,6 +1,10 @@
import apply from './_apply';
import arrayMap from './_arrayMap';
import baseFlatten from './_baseFlatten';
import baseIteratee from './_baseIteratee';
import baseUnary from './_baseUnary';
import isArray from './isArray';
import isFlattenableIteratee from './_isFlattenableIteratee';
import rest from './rest';
/**
@@ -12,7 +16,10 @@ import rest from './rest';
*/
function createOver(arrayFunc) {
return rest(function(iteratees) {
iteratees = arrayMap(iteratees, baseIteratee);
iteratees = (iteratees.length == 1 && isArray(iteratees[0]))
? arrayMap(iteratees[0], baseUnary(baseIteratee))
: arrayMap(baseFlatten(iteratees, 1, isFlattenableIteratee), baseUnary(baseIteratee));
return rest(function(args) {
var thisArg = this;
return arrayFunc(iteratees, function(iteratee) {

View File

@@ -1,19 +1,9 @@
import baseRepeat from './_baseRepeat';
import castSlice from './_castSlice';
import reHasComplexSymbol from './_reHasComplexSymbol';
import stringSize from './_stringSize';
import stringToArray from './_stringToArray';
/** Used to compose unicode character classes. */
var rsAstralRange = '\\ud800-\\udfff',
rsComboMarksRange = '\\u0300-\\u036f\\ufe20-\\ufe23',
rsComboSymbolsRange = '\\u20d0-\\u20f0',
rsVarRange = '\\ufe0e\\ufe0f';
/** Used to compose unicode capture groups. */
var rsZWJ = '\\u200d';
/** Used to detect strings with [zero-width joiners or code points from the astral planes](http://eev.ee/blog/2015/09/12/dark-corners-of-unicode/). */
var reHasComplexSymbol = RegExp('[' + rsZWJ + rsAstralRange + rsComboMarksRange + rsComboSymbolsRange + rsVarRange + ']');
/* Built-in method references for those with the same name as other `lodash` methods. */
var nativeCeil = Math.ceil;
@@ -35,7 +25,7 @@ function createPadding(length, chars) {
}
var result = baseRepeat(chars, nativeCeil(length / stringSize(chars)));
return reHasComplexSymbol.test(chars)
? stringToArray(result).slice(0, length).join('')
? castSlice(stringToArray(result), 0, length).join('')
: result.slice(0, length);
}

View File

@@ -1,4 +1,3 @@
import copyArray from './_copyArray';
import isLaziable from './_isLaziable';
import setData from './_setData';
@@ -30,7 +29,6 @@ var BIND_FLAG = 1,
*/
function createRecurryWrapper(func, bitmask, wrapFunc, placeholder, thisArg, partials, holders, argPos, ary, arity) {
var isCurry = bitmask & CURRY_FLAG,
newArgPos = argPos ? copyArray(argPos) : undefined,
newHolders = isCurry ? holders : undefined,
newHoldersRight = isCurry ? undefined : holders,
newPartials = isCurry ? partials : undefined,
@@ -44,7 +42,7 @@ function createRecurryWrapper(func, bitmask, wrapFunc, placeholder, thisArg, par
}
var newData = [
func, bitmask, thisArg, newPartials, newHolders, newPartialsRight,
newHoldersRight, newArgPos, ary, arity
newHoldersRight, argPos, ary, arity
];
var result = wrapFunc.apply(undefined, newData);

View File

@@ -51,8 +51,8 @@ if ((DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag) ||
(WeakMap && getTag(new WeakMap) != weakMapTag)) {
getTag = function(value) {
var result = objectToString.call(value),
Ctor = result == objectTag ? value.constructor : null,
ctorString = toSource(Ctor);
Ctor = result == objectTag ? value.constructor : undefined,
ctorString = Ctor ? toSource(Ctor) : undefined;
if (ctorString) {
switch (ctorString) {

View File

@@ -1,4 +1,4 @@
import baseCastPath from './_baseCastPath';
import castPath from './_castPath';
import isArguments from './isArguments';
import isArray from './isArray';
import isIndex from './_isIndex';
@@ -16,7 +16,7 @@ import isString from './isString';
* @returns {boolean} Returns `true` if `path` exists, else `false`.
*/
function hasPath(object, path, hasFunc) {
path = isKey(path, object) ? [path] : baseCastPath(path);
path = isKey(path, object) ? [path] : castPath(path);
var result,
index = -1,

16
_isFlattenable.js Normal file
View File

@@ -0,0 +1,16 @@
import isArguments from './isArguments';
import isArray from './isArray';
import isArrayLikeObject from './isArrayLikeObject';
/**
* Checks if `value` is a flattenable `arguments` object or array.
*
* @private
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is flattenable, else `false`.
*/
function isFlattenable(value) {
return isArrayLikeObject(value) && (isArray(value) || isArguments(value));
}
export default isFlattenable;

16
_isFlattenableIteratee.js Normal file
View File

@@ -0,0 +1,16 @@
import isArray from './isArray';
import isFunction from './isFunction';
/**
* Checks if `value` is a flattenable array and not a `_.matchesProperty`
* iteratee shorthand.
*
* @private
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is flattenable, else `false`.
*/
function isFlattenableIteratee(value) {
return isArray(value) && !(value.length == 2 && !isFunction(value[0]));
}
export default isFlattenableIteratee;

View File

@@ -1,6 +1,5 @@
import composeArgs from './_composeArgs';
import composeArgsRight from './_composeArgsRight';
import copyArray from './_copyArray';
import replaceHolders from './_replaceHolders';
/** Used as the internal argument placeholder. */
@@ -58,20 +57,20 @@ function mergeData(data, source) {
var value = source[3];
if (value) {
var partials = data[3];
data[3] = partials ? composeArgs(partials, value, source[4]) : copyArray(value);
data[4] = partials ? replaceHolders(data[3], PLACEHOLDER) : copyArray(source[4]);
data[3] = partials ? composeArgs(partials, value, source[4]) : value;
data[4] = partials ? replaceHolders(data[3], PLACEHOLDER) : source[4];
}
// Compose partial right arguments.
value = source[5];
if (value) {
partials = data[5];
data[5] = partials ? composeArgsRight(partials, value, source[6]) : copyArray(value);
data[6] = partials ? replaceHolders(data[5], PLACEHOLDER) : copyArray(source[6]);
data[5] = partials ? composeArgsRight(partials, value, source[6]) : value;
data[6] = partials ? replaceHolders(data[5], PLACEHOLDER) : source[6];
}
// Use source `argPos` if available.
value = source[7];
if (value) {
data[7] = copyArray(value);
data[7] = value;
}
// Use source `ary` if it's smaller.
if (srcBitmask & ARY_FLAG) {

13
_reHasComplexSymbol.js Normal file
View File

@@ -0,0 +1,13 @@
/** Used to compose unicode character classes. */
var rsAstralRange = '\\ud800-\\udfff',
rsComboMarksRange = '\\u0300-\\u036f\\ufe20-\\ufe23',
rsComboSymbolsRange = '\\u20d0-\\u20f0',
rsVarRange = '\\ufe0e\\ufe0f';
/** Used to compose unicode capture groups. */
var rsZWJ = '\\u200d';
/** Used to detect strings with [zero-width joiners or code points from the astral planes](http://eev.ee/blog/2015/09/12/dark-corners-of-unicode/). */
var reHasComplexSymbol = RegExp('[' + rsZWJ + rsAstralRange + rsComboMarksRange + rsComboSymbolsRange + rsVarRange + ']');
export default reHasComplexSymbol;

View File

@@ -1,3 +1,5 @@
import reHasComplexSymbol from './_reHasComplexSymbol';
/** Used to compose unicode character classes. */
var rsAstralRange = '\\ud800-\\udfff',
rsComboMarksRange = '\\u0300-\\u036f\\ufe20-\\ufe23',
@@ -24,9 +26,6 @@ var reOptMod = rsModifier + '?',
/** Used to match [string symbols](https://mathiasbynens.be/notes/javascript-unicode). */
var reComplexSymbol = RegExp(rsFitz + '(?=' + rsFitz + ')|' + rsSymbol + rsSeq, 'g');
/** Used to detect strings with [zero-width joiners or code points from the astral planes](http://eev.ee/blog/2015/09/12/dark-corners-of-unicode/). */
var reHasComplexSymbol = RegExp('[' + rsZWJ + rsAstralRange + rsComboMarksRange + rsComboSymbolsRange + rsVarRange + ']');
/**
* Gets the number of symbols in `string`.
*

View File

@@ -1,14 +1,14 @@
import isSymbol from './isSymbol';
/**
* Casts `value` to a string if it's not a string or symbol.
* Converts `value` to a string key if it's not a string or symbol.
*
* @private
* @param {*} value The value to inspect.
* @returns {string|symbol} Returns the cast key.
* @returns {string|symbol} Returns the key.
*/
function baseCastKey(key) {
function toKey(key) {
return (typeof key == 'string' || isSymbol(key)) ? key : (key + '');
}
export default baseCastKey;
export default toKey;

View File

@@ -1,6 +1,3 @@
import isFunction from './isFunction';
import toString from './toString';
/** Used to resolve the decompiled source of functions. */
var funcToString = Function.prototype.toString;
@@ -12,12 +9,15 @@ var funcToString = Function.prototype.toString;
* @returns {string} Returns the source code.
*/
function toSource(func) {
if (isFunction(func)) {
if (func != null) {
try {
return funcToString.call(func);
} catch (e) {}
try {
return (func + '');
} catch (e) {}
}
return toString(func);
return '';
}
export default toSource;

View File

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

View File

@@ -24,6 +24,7 @@ export { default as intersectionWith } from './intersectionWith';
export { default as join } from './join';
export { default as last } from './last';
export { default as lastIndexOf } from './lastIndexOf';
export { default as nth } from './nth';
export { default as pull } from './pull';
export { default as pullAll } from './pullAll';
export { default as pullAllBy } from './pullAllBy';

View File

@@ -1,11 +1,11 @@
import copyObjectWith from './_copyObjectWith';
import copyObject from './_copyObject';
import createAssigner from './_createAssigner';
import keysIn from './keysIn';
/**
* This method is like `_.assignIn` except that it accepts `customizer`
* which is invoked to produce the assigned values. If `customizer` returns
* `undefined` assignment is handled by the method instead. The `customizer`
* `undefined`, assignment is handled by the method instead. The `customizer`
* is invoked with five arguments: (objValue, srcValue, key, object, source).
*
* **Note:** This method mutates `object`.
@@ -31,7 +31,7 @@ import keysIn from './keysIn';
* // => { 'a': 1, 'b': 2 }
*/
var assignInWith = createAssigner(function(object, source, srcIndex, customizer) {
copyObjectWith(source, keysIn(source), object, customizer);
copyObject(source, keysIn(source), object, customizer);
});
export default assignInWith;

View File

@@ -1,11 +1,11 @@
import copyObjectWith from './_copyObjectWith';
import copyObject from './_copyObject';
import createAssigner from './_createAssigner';
import keys from './keys';
/**
* This method is like `_.assign` except that it accepts `customizer`
* which is invoked to produce the assigned values. If `customizer` returns
* `undefined` assignment is handled by the method instead. The `customizer`
* `undefined`, assignment is handled by the method instead. The `customizer`
* is invoked with five arguments: (objValue, srcValue, key, object, source).
*
* **Note:** This method mutates `object`.
@@ -30,7 +30,7 @@ import keys from './keys';
* // => { 'a': 1, 'b': 2 }
*/
var assignWith = createAssigner(function(object, source, srcIndex, customizer) {
copyObjectWith(source, keys(source), object, customizer);
copyObject(source, keys(source), object, customizer);
});
export default assignWith;

3
at.js
View File

@@ -10,8 +10,7 @@ import rest from './rest';
* @since 1.0.0
* @category Object
* @param {Object} object The object to iterate over.
* @param {...(string|string[])} [paths] The property paths of elements to pick,
* specified individually or in arrays.
* @param {...(string|string[])} [paths] The property paths of elements to pick.
* @returns {Array} Returns the new array of picked elements.
* @example
*

View File

@@ -14,8 +14,7 @@ import rest from './rest';
* @memberOf _
* @category Util
* @param {Object} object The object to bind and assign the bound methods to.
* @param {...(string|string[])} methodNames The object method names to bind,
* specified individually or in arrays.
* @param {...(string|string[])} methodNames The object method names to bind.
* @returns {Object} Returns `object`.
* @example
*

View File

@@ -2,7 +2,7 @@ import baseClone from './_baseClone';
/**
* This method is like `_.clone` except that it accepts `customizer` which
* is invoked to produce the cloned value. If `customizer` returns `undefined`
* is invoked to produce the cloned value. If `customizer` returns `undefined`,
* cloning is handled by the method instead. The `customizer` is invoked with
* up to four arguments; (value [, index|key, object, stack]).
*

View File

@@ -7,7 +7,7 @@ import rest from './rest';
var FUNC_ERROR_TEXT = 'Expected a function';
/**
* Creates a function that iterates over `pairs` invoking the corresponding
* Creates a function that iterates over `pairs` and invokes the corresponding
* function of the first predicate to return truthy. The predicate-function
* pairs are invoked with the `this` binding and arguments of the created
* function.

View File

@@ -3,7 +3,7 @@ import baseCreate from './_baseCreate';
/**
* Creates an object that inherits from the `prototype` object. If a
* `properties` object is given its own enumerable string keyed properties
* `properties` object is given, its own enumerable string keyed properties
* are assigned to the created object.
*
* @static

View File

@@ -23,7 +23,7 @@ var nativeMax = Math.max,
* on the trailing edge of the timeout only if the debounced function is
* invoked more than once during the `wait` timeout.
*
* See [David Corbacho's article](http://drupalmotion.com/article/debounce-and-throttle-visual-explanation)
* See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
* for details over the differences between `_.debounce` and `_.throttle`.
*
* @static
@@ -169,6 +169,9 @@ function debounce(func, wait, options) {
timerId = setTimeout(timerExpired, wait);
return invokeFunc(lastCallTime);
}
if (timerId === undefined) {
timerId = setTimeout(timerExpired, wait);
}
return result;
}
debounced.cancel = cancel;

View File

@@ -23,7 +23,7 @@ import rest from './rest';
*/
var difference = rest(function(array, values) {
return isArrayLikeObject(array)
? baseDifference(array, baseFlatten(values, 1, true))
? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true))
: [];
});

View File

@@ -35,7 +35,7 @@ var differenceBy = rest(function(array, values) {
iteratee = undefined;
}
return isArrayLikeObject(array)
? baseDifference(array, baseFlatten(values, 1, true), baseIteratee(iteratee))
? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true), baseIteratee(iteratee))
: [];
});

View File

@@ -31,7 +31,7 @@ var differenceWith = rest(function(array, values) {
comparator = undefined;
}
return isArrayLikeObject(array)
? baseDifference(array, baseFlatten(values, 1, true), undefined, comparator)
? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true), undefined, comparator)
: [];
});

View File

@@ -4,7 +4,7 @@ import baseIteratee from './_baseIteratee';
import isArray from './isArray';
/**
* Iterates over elements of `collection` invoking `iteratee` for each element.
* Iterates over elements of `collection` and invokes `iteratee` for each element.
* The iteratee is invoked with three arguments: (value, index|key, collection).
* Iteratee functions may exit iteration early by explicitly returning `false`.
*

View File

@@ -4,9 +4,9 @@ import keysIn from './keysIn';
/**
* Iterates over own and inherited enumerable string keyed properties of an
* object invoking `iteratee` for each property. The iteratee is invoked with
* three arguments: (value, key, object). Iteratee functions may exit iteration
* early by explicitly returning `false`.
* object and invokes `iteratee` for each property. The iteratee is invoked
* with three arguments: (value, key, object). Iteratee functions may exit
* iteration early by explicitly returning `false`.
*
* @static
* @memberOf _

View File

@@ -2,10 +2,10 @@ import baseForOwn from './_baseForOwn';
import baseIteratee from './_baseIteratee';
/**
* Iterates over own enumerable string keyed properties of an object invoking
* `iteratee` for each property. The iteratee is invoked with three arguments:
* (value, key, object). Iteratee functions may exit iteration early by
* explicitly returning `false`.
* Iterates over own enumerable string keyed properties of an object and
* invokes `iteratee` for each property. The iteratee is invoked with three
* arguments: (value, key, object). Iteratee functions may exit iteration
* early by explicitly returning `false`.
*
* @static
* @memberOf _

2
get.js
View File

@@ -2,7 +2,7 @@ import baseGet from './_baseGet';
/**
* Gets the value at `path` of `object`. If the resolved value is
* `undefined` the `defaultValue` is used in its place.
* `undefined`, the `defaultValue` is used in its place.
*
* @static
* @memberOf _

View File

@@ -8,9 +8,10 @@ var hasOwnProperty = objectProto.hasOwnProperty;
/**
* Creates an object composed of keys generated from the results of running
* each element of `collection` thru `iteratee`. The corresponding value of
* each key is an array of elements responsible for generating the key. The
* iteratee is invoked with one argument: (value).
* each element of `collection` thru `iteratee`. The order of grouped values
* is determined by the order they occur in `collection`. The corresponding
* value of each key is an array of elements responsible for generating the
* key. The iteratee is invoked with one argument: (value).
*
* @static
* @memberOf _

8
has.js
View File

@@ -13,16 +13,16 @@ import hasPath from './_hasPath';
* @returns {boolean} Returns `true` if `path` exists, else `false`.
* @example
*
* var object = { 'a': { 'b': { 'c': 3 } } };
* var other = _.create({ 'a': _.create({ 'b': _.create({ 'c': 3 }) }) });
* var object = { 'a': { 'b': 2 } };
* var other = _.create({ 'a': _.create({ 'b': 2 }) });
*
* _.has(object, 'a');
* // => true
*
* _.has(object, 'a.b.c');
* _.has(object, 'a.b');
* // => true
*
* _.has(object, ['a', 'b', 'c']);
* _.has(object, ['a', 'b']);
* // => true
*
* _.has(other, 'a');

View File

@@ -13,15 +13,15 @@ import hasPath from './_hasPath';
* @returns {boolean} Returns `true` if `path` exists, else `false`.
* @example
*
* var object = _.create({ 'a': _.create({ 'b': _.create({ 'c': 3 }) }) });
* var object = _.create({ 'a': _.create({ 'b': 2 }) });
*
* _.hasIn(object, 'a');
* // => true
*
* _.hasIn(object, 'a.b.c');
* _.hasIn(object, 'a.b');
* // => true
*
* _.hasIn(object, ['a', 'b', 'c']);
* _.hasIn(object, ['a', 'b']);
* // => true
*
* _.hasIn(object, 'b');

View File

@@ -17,7 +17,7 @@
* // => undefined
*/
function head(array) {
return array ? array[0] : undefined;
return (array && array.length) ? array[0] : undefined;
}
export default head;

View File

@@ -3,7 +3,7 @@ import toNumber from './toNumber';
/**
* Checks if `n` is between `start` and up to but not including, `end`. If
* `end` is not specified it's set to `start` with `start` then set to `0`.
* `end` is not specified, it's set to `start` with `start` then set to `0`.
* If `start` is greater than `end` the params are swapped to support
* negative ranges.
*

View File

@@ -8,7 +8,7 @@ import values from './values';
var nativeMax = Math.max;
/**
* Checks if `value` is in `collection`. If `collection` is a string it's
* Checks if `value` is in `collection`. If `collection` is a string, it's
* checked for a substring of `value`, otherwise
* [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero)
* is used for equality comparisons. If `fromIndex` is negative, it's used as

View File

@@ -7,8 +7,8 @@ var nativeMax = Math.max;
/**
* Gets the index at which the first occurrence of `value` is found in `array`
* using [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero)
* for equality comparisons. If `fromIndex` is negative, it's used as the offset
* from the end of `array`.
* for equality comparisons. If `fromIndex` is negative, it's used as the
* offset from the end of `array`.
*
* @static
* @memberOf _

View File

@@ -1,6 +1,6 @@
import arrayMap from './_arrayMap';
import baseCastArrayLikeObject from './_baseCastArrayLikeObject';
import baseIntersection from './_baseIntersection';
import castArrayLikeObject from './_castArrayLikeObject';
import rest from './rest';
/**
@@ -21,7 +21,7 @@ import rest from './rest';
* // => [2]
*/
var intersection = rest(function(arrays) {
var mapped = arrayMap(arrays, baseCastArrayLikeObject);
var mapped = arrayMap(arrays, castArrayLikeObject);
return (mapped.length && mapped[0] === arrays[0])
? baseIntersection(mapped)
: [];

View File

@@ -1,7 +1,7 @@
import arrayMap from './_arrayMap';
import baseCastArrayLikeObject from './_baseCastArrayLikeObject';
import baseIntersection from './_baseIntersection';
import baseIteratee from './_baseIteratee';
import castArrayLikeObject from './_castArrayLikeObject';
import last from './last';
import rest from './rest';
@@ -30,7 +30,7 @@ import rest from './rest';
*/
var intersectionBy = rest(function(arrays) {
var iteratee = last(arrays),
mapped = arrayMap(arrays, baseCastArrayLikeObject);
mapped = arrayMap(arrays, castArrayLikeObject);
if (iteratee === last(mapped)) {
iteratee = undefined;

View File

@@ -1,6 +1,6 @@
import arrayMap from './_arrayMap';
import baseCastArrayLikeObject from './_baseCastArrayLikeObject';
import baseIntersection from './_baseIntersection';
import castArrayLikeObject from './_castArrayLikeObject';
import last from './last';
import rest from './rest';
@@ -27,7 +27,7 @@ import rest from './rest';
*/
var intersectionWith = rest(function(arrays) {
var comparator = last(arrays),
mapped = arrayMap(arrays, baseCastArrayLikeObject);
mapped = arrayMap(arrays, castArrayLikeObject);
if (comparator === last(mapped)) {
comparator = undefined;

View File

@@ -8,8 +8,8 @@ import rest from './rest';
/**
* Invokes the method at `path` of each element in `collection`, returning
* an array of the results of each invoked method. Any additional arguments
* are provided to each invoked method. If `methodName` is a function it's
* invoked for, and `this` bound to, each element in `collection`.
* are provided to each invoked method. If `methodName` is a function, it's
* invoked for and `this` bound to, each element in `collection`.
*
* @static
* @memberOf _

View File

@@ -2,7 +2,7 @@ import baseIsEqual from './_baseIsEqual';
/**
* This method is like `_.isEqual` except that it accepts `customizer` which
* is invoked to compare values. If `customizer` returns `undefined` comparisons
* is invoked to compare values. If `customizer` returns `undefined`, comparisons
* are handled by the method instead. The `customizer` is invoked with up to
* six arguments: (objValue, othValue [, index|key, object, other, stack]).
*

View File

@@ -3,7 +3,7 @@ import getMatchData from './_getMatchData';
/**
* This method is like `_.isMatch` except that it accepts `customizer` which
* is invoked to compare values. If `customizer` returns `undefined` comparisons
* is invoked to compare values. If `customizer` returns `undefined`, comparisons
* are handled by the method instead. The `customizer` is invoked with five
* arguments: (objValue, srcValue, index|key, object, source).
*

View File

@@ -3,8 +3,8 @@ import baseIteratee from './_baseIteratee';
/**
* Creates a function that invokes `func` with the arguments of the created
* function. If `func` is a property name the created function returns the
* property value for a given element. If `func` is an array or object the
* function. If `func` is a property name, the created function returns the
* property value for a given element. If `func` is an array or object, the
* created function returns `true` for elements that contain the equivalent
* source properties, otherwise it returns `false`.
*

View File

@@ -1,6 +1,6 @@
/**
* @license
* lodash 4.8.0 (Custom Build) <https://lodash.com/>
* lodash 4.11.0 (Custom Build) <https://lodash.com/>
* Build: `lodash modularize exports="es" -o ./`
* Copyright jQuery Foundation and other contributors <https://jquery.org/>
* Released under MIT license <https://lodash.com/license>
@@ -44,7 +44,7 @@ import toInteger from './toInteger';
import lodash from './wrapperLodash';
/** Used as the semantic version number. */
var VERSION = '4.8.0';
var VERSION = '4.11.0';
/** Used to compose bitmasks for wrapper metadata. */
var BIND_KEY_FLAG = 2;
@@ -342,6 +342,7 @@ lodash.meanBy = math.meanBy;
lodash.min = math.min;
lodash.minBy = math.minBy;
lodash.multiply = math.multiply;
lodash.nth = array.nth;
lodash.noop = util.noop;
lodash.now = date.now;
lodash.pad = string.pad;

View File

@@ -1,6 +1,6 @@
/**
* @license
* lodash 4.8.0 (Custom Build) <https://lodash.com/>
* lodash 4.11.0 (Custom Build) <https://lodash.com/>
* Build: `lodash modularize exports="es" -o ./`
* Copyright jQuery Foundation and other contributors <https://jquery.org/>
* Released under MIT license <https://lodash.com/license>
@@ -184,6 +184,7 @@ export { default as negate } from './negate';
export { default as next } from './next';
export { default as noop } from './noop';
export { default as now } from './now';
export { default as nth } from './nth';
export { default as nthArg } from './nthArg';
export { default as omit } from './omit';
export { default as omitBy } from './omitBy';

4
map.js
View File

@@ -14,8 +14,8 @@ import isArray from './isArray';
* The guarded methods are:
* `ary`, `chunk`, `curry`, `curryRight`, `drop`, `dropRight`, `every`,
* `fill`, `invert`, `parseInt`, `random`, `range`, `rangeRight`, `repeat`,
* `sampleSize`, `slice`, `some`, `sortBy`, `take`, `takeRight`, `template`,
* `trim`, `trimEnd`, `trimStart`, and `words`
* `sampleSize`, `slice`, `some`, `sortBy`, `split`, `take`, `takeRight`,
* `template`, `trim`, `trimEnd`, `trimStart`, and `words`
*
* @static
* @memberOf _

2
max.js
View File

@@ -3,7 +3,7 @@ import gt from './gt';
import identity from './identity';
/**
* Computes the maximum value of `array`. If `array` is empty or falsey
* Computes the maximum value of `array`. If `array` is empty or falsey,
* `undefined` is returned.
*
* @static

View File

@@ -5,7 +5,7 @@ var FUNC_ERROR_TEXT = 'Expected a function';
/**
* Creates a function that memoizes the result of `func`. If `resolver` is
* provided it determines the cache key for storing the result based on the
* provided, it determines the cache key for storing the result based on the
* arguments provided to the memoized function. By default, the first argument
* provided to the memoized function is used as the map cache key. The `func`
* is invoked with the `this` binding of the memoized function.

View File

@@ -4,7 +4,7 @@ import createAssigner from './_createAssigner';
/**
* This method is like `_.merge` except that it accepts `customizer` which
* is invoked to produce the merged values of the destination and source
* properties. If `customizer` returns `undefined` merging is handled by the
* properties. If `customizer` returns `undefined`, merging is handled by the
* method instead. The `customizer` is invoked with seven arguments:
* (objValue, srcValue, key, object, source, stack).
*

View File

@@ -15,14 +15,14 @@ import rest from './rest';
* @example
*
* var objects = [
* { 'a': { 'b': { 'c': _.constant(2) } } },
* { 'a': { 'b': { 'c': _.constant(1) } } }
* { 'a': { 'b': _.constant(2) } },
* { 'a': { 'b': _.constant(1) } }
* ];
*
* _.map(objects, _.method('a.b.c'));
* _.map(objects, _.method('a.b'));
* // => [2, 1]
*
* _.map(objects, _.method(['a', 'b', 'c']));
* _.map(objects, _.method(['a', 'b']));
* // => [2, 1]
*/
var method = rest(function(path, args) {

2
min.js
View File

@@ -3,7 +3,7 @@ import identity from './identity';
import lt from './lt';
/**
* Computes the minimum value of `array`. If `array` is empty or falsey
* Computes the minimum value of `array`. If `array` is empty or falsey,
* `undefined` is returned.
*
* @static

View File

@@ -8,7 +8,7 @@ import keys from './keys';
/**
* Adds all own enumerable string keyed function properties of a source
* object to the destination object. If `object` is a function then methods
* object to the destination object. If `object` is a function, then methods
* are added to its prototype as well.
*
* **Note:** Use `_.runInContext` to create a pristine `lodash` function to

29
nth.js Normal file
View File

@@ -0,0 +1,29 @@
import baseNth from './_baseNth';
import toInteger from './toInteger';
/**
* Gets the nth element of `array`. If `n` is negative, the nth element
* from the end is returned.
*
* @static
* @memberOf _
* @since 4.11.0
* @category Array
* @param {Array} array The array to query.
* @param {number} [n=0] The index of the element to return.
* @returns {*} Returns the nth element of `array`.
* @example
*
* var array = ['a', 'b', 'c', 'd'];
*
* _.nth(array, 1);
* // => 'b'
*
* _.nth(array, -2);
* // => 'c';
*/
function nth(array, n) {
return (array && array.length) ? baseNth(array, toInteger(n)) : undefined;
}
export default nth;

View File

@@ -1,7 +1,10 @@
import baseNth from './_baseNth';
import rest from './rest';
import toInteger from './toInteger';
/**
* Creates a function that returns its nth argument.
* Creates a function that returns its nth argument. If `n` is negative,
* the nth argument from the end is returned.
*
* @static
* @memberOf _
@@ -12,15 +15,18 @@ import toInteger from './toInteger';
* @example
*
* var func = _.nthArg(1);
*
* func('a', 'b', 'c');
* func('a', 'b', 'c', 'd');
* // => 'b'
*
* var func = _.nthArg(-2);
* func('a', 'b', 'c', 'd');
* // => 'c'
*/
function nthArg(n) {
n = toInteger(n);
return function() {
return arguments[n];
};
return rest(function(args) {
return baseNth(args, n);
});
}
export default nthArg;

View File

@@ -1,10 +1,10 @@
import arrayMap from './_arrayMap';
import baseCastKey from './_baseCastKey';
import baseDifference from './_baseDifference';
import baseFlatten from './_baseFlatten';
import basePick from './_basePick';
import getAllKeysIn from './_getAllKeysIn';
import rest from './rest';
import toKey from './_toKey';
/**
* The opposite of `_.pick`; this method creates an object composed of the
@@ -16,8 +16,7 @@ import rest from './rest';
* @memberOf _
* @category Object
* @param {Object} object The source object.
* @param {...(string|string[])} [props] The property identifiers to omit,
* specified individually or in arrays.
* @param {...(string|string[])} [props] The property identifiers to omit.
* @returns {Object} Returns the new object.
* @example
*
@@ -30,7 +29,7 @@ var omit = rest(function(object, props) {
if (object == null) {
return {};
}
props = arrayMap(baseFlatten(props, 1), baseCastKey);
props = arrayMap(baseFlatten(props, 1), toKey);
return basePick(object, baseDifference(getAllKeysIn(object), props));
});

View File

@@ -9,7 +9,8 @@ import createOver from './_createOver';
* @memberOf _
* @since 4.0.0
* @category Util
* @param {...Function} iteratees The iteratees to invoke.
* @param {...(Array|Array[]|Function|Function[]|Object|Object[]|string|string[])}
* [iteratees=[_.identity]] The iteratees to invoke.
* @returns {Function} Returns the new function.
* @example
*

View File

@@ -1,6 +1,10 @@
import apply from './_apply';
import arrayMap from './_arrayMap';
import baseFlatten from './_baseFlatten';
import baseIteratee from './_baseIteratee';
import baseUnary from './_baseUnary';
import isArray from './isArray';
import isFlattenableIteratee from './_isFlattenableIteratee';
import rest from './rest';
/* Built-in method references for those with the same name as other `lodash` methods. */
@@ -15,8 +19,8 @@ var nativeMin = Math.min;
* @memberOf _
* @category Function
* @param {Function} func The function to wrap.
* @param {...Function} [transforms] The functions to transform
* arguments, specified individually or in arrays.
* @param {...(Array|Array[]|Function|Function[]|Object|Object[]|string|string[])}
* [transforms[_.identity]] The functions to transform.
* @returns {Function} Returns the new function.
* @example
*
@@ -39,7 +43,9 @@ var nativeMin = Math.min;
* // => [100, 10]
*/
var overArgs = rest(function(func, transforms) {
transforms = arrayMap(transforms, baseIteratee);
transforms = (transforms.length == 1 && isArray(transforms[0]))
? arrayMap(transforms[0], baseUnary(baseIteratee))
: arrayMap(baseFlatten(transforms, 1, isFlattenableIteratee), baseUnary(baseIteratee));
var funcsLength = transforms.length;
return rest(function(args) {

View File

@@ -9,7 +9,8 @@ import createOver from './_createOver';
* @memberOf _
* @since 4.0.0
* @category Util
* @param {...Function} predicates The predicates to check.
* @param {...(Array|Array[]|Function|Function[]|Object|Object[]|string|string[])}
* [predicates=[_.identity]] The predicates to check.
* @returns {Function} Returns the new function.
* @example
*

View File

@@ -9,7 +9,8 @@ import createOver from './_createOver';
* @memberOf _
* @since 4.0.0
* @category Util
* @param {...Function} predicates The predicates to check.
* @param {...(Array|Array[]|Function|Function[]|Object|Object[]|string|string[])}
* [predicates=[_.identity]] The predicates to check.
* @returns {Function} Returns the new function.
* @example
*

View File

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

View File

@@ -10,8 +10,7 @@ import rest from './rest';
* @memberOf _
* @category Object
* @param {Object} object The source object.
* @param {...(string|string[])} [props] The property identifiers to pick,
* specified individually or in arrays.
* @param {...(string|string[])} [props] The property identifiers to pick.
* @returns {Object} Returns the new object.
* @example
*

View File

@@ -14,14 +14,14 @@ import isKey from './_isKey';
* @example
*
* var objects = [
* { 'a': { 'b': { 'c': 2 } } },
* { 'a': { 'b': { 'c': 1 } } }
* { 'a': { 'b': 2 } },
* { 'a': { 'b': 1 } }
* ];
*
* _.map(objects, _.property('a.b.c'));
* _.map(objects, _.property('a.b'));
* // => [2, 1]
*
* _.map(_.sortBy(objects, _.property(['a', 'b', 'c'])), 'a.b.c');
* _.map(_.sortBy(objects, _.property(['a', 'b'])), 'a.b');
* // => [1, 2]
*/
function property(path) {

View File

@@ -16,8 +16,7 @@ import rest from './rest';
* @since 3.0.0
* @category Array
* @param {Array} array The array to modify.
* @param {...(number|number[])} [indexes] The indexes of elements to remove,
* specified individually or in arrays.
* @param {...(number|number[])} [indexes] The indexes of elements to remove.
* @returns {Array} Returns the new array of removed elements.
* @example
*

View File

@@ -3,7 +3,7 @@ import createRange from './_createRange';
/**
* Creates an array of numbers (positive and/or negative) progressing from
* `start` up to, but not including, `end`. A step of `-1` is used if a negative
* `start` is specified without an `end` or `step`. If `end` is not specified
* `start` is specified without an `end` or `step`. If `end` is not specified,
* it's set to `start` with `start` then set to `0`.
*
* **Note:** JavaScript follows the IEEE-754 standard for resolving

View File

@@ -16,8 +16,7 @@ var REARG_FLAG = 256;
* @since 3.0.0
* @category Function
* @param {Function} func The function to rearrange arguments for.
* @param {...(number|number[])} indexes The arranged argument indexes,
* specified individually or in arrays.
* @param {...(number|number[])} indexes The arranged argument indexes.
* @returns {Function} Returns the new function.
* @example
*

View File

@@ -8,7 +8,7 @@ import isArray from './isArray';
* Reduces `collection` to a value which is the accumulated result of running
* each element in `collection` thru `iteratee`, where each successive
* invocation is supplied the return value of the previous. If `accumulator`
* is not given the first element of `collection` is used as the initial
* is not given, the first element of `collection` is used as the initial
* value. The iteratee is invoked with four arguments:
* (accumulator, value, index|key, collection).
*

View File

@@ -1,5 +1,11 @@
import toString from './toString';
/** Used for built-in method references. */
var stringProto = String.prototype;
/* Built-in method references for those with the same name as other `lodash` methods. */
var nativeReplace = stringProto.replace;
/**
* Replaces matches for `pattern` in `string` with `replacement`.
*
@@ -23,7 +29,7 @@ function replace() {
var args = arguments,
string = toString(args[0]);
return args.length < 3 ? string : string.replace(args[1], args[2]);
return args.length < 3 ? string : nativeReplace.call(string, args[1], args[2]);
}
export default replace;

View File

@@ -1,4 +1,4 @@
import baseCastPath from './_baseCastPath';
import castPath from './_castPath';
import isFunction from './isFunction';
import isKey from './_isKey';
@@ -32,7 +32,7 @@ import isKey from './_isKey';
* // => 'default'
*/
function result(object, path, defaultValue) {
path = isKey(path, object) ? [path] : baseCastPath(path);
path = isKey(path, object) ? [path] : castPath(path);
var index = -1,
length = path.length;

2
set.js
View File

@@ -1,7 +1,7 @@
import baseSet from './_baseSet';
/**
* Sets the value at `path` of `object`. If a portion of `path` doesn't exist
* Sets the value at `path` of `object`. If a portion of `path` doesn't exist,
* it's created. Arrays are created for missing index properties while objects
* are created for all other missing properties. Use `_.setWith` to customize
* `path` creation.

View File

@@ -1,5 +1,7 @@
import baseFlatten from './_baseFlatten';
import baseOrderBy from './_baseOrderBy';
import isArray from './isArray';
import isFlattenableIteratee from './_isFlattenableIteratee';
import isIterateeCall from './_isIterateeCall';
import rest from './rest';
@@ -15,8 +17,7 @@ import rest from './rest';
* @category Collection
* @param {Array|Object} collection The collection to iterate over.
* @param {...(Array|Array[]|Function|Function[]|Object|Object[]|string|string[])}
* [iteratees=[_.identity]] The iteratees to sort by, specified individually
* or in arrays.
* [iteratees=[_.identity]] The iteratees to sort by.
* @returns {Array} Returns the new sorted array.
* @example
*
@@ -46,9 +47,13 @@ var sortBy = rest(function(collection, iteratees) {
if (length > 1 && isIterateeCall(collection, iteratees[0], iteratees[1])) {
iteratees = [];
} else if (length > 2 && isIterateeCall(iteratees[0], iteratees[1], iteratees[2])) {
iteratees.length = 1;
iteratees = [iteratees[0]];
}
return baseOrderBy(collection, baseFlatten(iteratees, 1), []);
iteratees = (iteratees.length == 1 && isArray(iteratees[0]))
? iteratees[0]
: baseFlatten(iteratees, 1, isFlattenableIteratee);
return baseOrderBy(collection, iteratees, []);
});
export default sortBy;

View File

@@ -1,5 +1,19 @@
import castSlice from './_castSlice';
import isIterateeCall from './_isIterateeCall';
import isRegExp from './isRegExp';
import reHasComplexSymbol from './_reHasComplexSymbol';
import stringToArray from './_stringToArray';
import toString from './toString';
/** Used as references for the maximum length and index of an array. */
var MAX_ARRAY_LENGTH = 4294967295;
/** Used for built-in method references. */
var stringProto = String.prototype;
/* Built-in method references for those with the same name as other `lodash` methods. */
var nativeSplit = stringProto.split;
/**
* Splits `string` by `separator`.
*
@@ -20,7 +34,24 @@ import toString from './toString';
* // => ['a', 'b']
*/
function split(string, separator, limit) {
return toString(string).split(separator, limit);
if (limit && typeof limit != 'number' && isIterateeCall(string, separator, limit)) {
separator = limit = undefined;
}
limit = limit === undefined ? MAX_ARRAY_LENGTH : limit >>> 0;
if (!limit) {
return [];
}
string = toString(string);
if (string && (
typeof separator == 'string' ||
(separator != null && !isRegExp(separator))
)) {
separator += '';
if (separator == '' && reHasComplexSymbol.test(string)) {
return castSlice(stringToArray(string), 0, limit);
}
}
return nativeSplit.call(string, separator, limit);
}
export default split;

View File

@@ -1,5 +1,6 @@
import apply from './_apply';
import arrayPush from './_arrayPush';
import castSlice from './_castSlice';
import rest from './rest';
import toInteger from './toInteger';
@@ -50,7 +51,7 @@ function spread(func, start) {
start = start === undefined ? 0 : nativeMax(toInteger(start), 0);
return rest(function(args) {
var array = args[start],
otherArgs = args.slice(0, start);
otherArgs = castSlice(args, 0, start);
if (array) {
arrayPush(otherArgs, array);

View File

@@ -32,7 +32,7 @@ var reUnescapedString = /['\n\r\u2028\u2029\\]/g;
* in "interpolate" delimiters, HTML-escape interpolated data properties in
* "escape" delimiters, and execute JavaScript in "evaluate" delimiters. Data
* properties may be accessed as free variables in the template. If a setting
* object is given it takes precedence over `_.templateSettings` values.
* object is given, it takes precedence over `_.templateSettings` values.
*
* **Note:** In the development build `_.template` utilizes
* [sourceURLs](http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl)

View File

@@ -18,7 +18,7 @@ var FUNC_ERROR_TEXT = 'Expected a function';
* invoked on the trailing edge of the timeout only if the throttled function
* is invoked more than once during the `wait` timeout.
*
* See [David Corbacho's article](http://drupalmotion.com/article/debounce-and-throttle-visual-explanation)
* See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
* for details over the differences between `_.throttle` and `_.debounce`.
*
* @static

View File

@@ -1,9 +1,9 @@
import arrayMap from './_arrayMap';
import baseCastKey from './_baseCastKey';
import copyArray from './_copyArray';
import isArray from './isArray';
import isSymbol from './isSymbol';
import stringToPath from './_stringToPath';
import toKey from './_toKey';
/**
* Converts `value` to a property path array.
@@ -33,7 +33,7 @@ import stringToPath from './_stringToPath';
*/
function toPath(value) {
if (isArray(value)) {
return arrayMap(value, baseCastKey);
return arrayMap(value, toKey);
}
return isSymbol(value) ? [value] : copyArray(stringToPath(value));
}

View File

@@ -9,8 +9,8 @@ var symbolProto = Symbol ? Symbol.prototype : undefined,
symbolToString = symbolProto ? symbolProto.toString : undefined;
/**
* Converts `value` to a string if it's not one. An empty string is returned
* for `null` and `undefined` values. The sign of `-0` is preserved.
* Converts `value` to a string. An empty string is returned for `null`
* and `undefined` values. The sign of `-0` is preserved.
*
* @static
* @memberOf _

12
trim.js
View File

@@ -1,3 +1,4 @@
import castSlice from './_castSlice';
import charsEndIndex from './_charsEndIndex';
import charsStartIndex from './_charsStartIndex';
import stringToArray from './_stringToArray';
@@ -36,16 +37,15 @@ function trim(string, chars, guard) {
if (guard || chars === undefined) {
return string.replace(reTrim, '');
}
chars = (chars + '');
if (!chars) {
if (!(chars += '')) {
return string;
}
var strSymbols = stringToArray(string),
chrSymbols = stringToArray(chars);
chrSymbols = stringToArray(chars),
start = charsStartIndex(strSymbols, chrSymbols),
end = charsEndIndex(strSymbols, chrSymbols) + 1;
return strSymbols
.slice(charsStartIndex(strSymbols, chrSymbols), charsEndIndex(strSymbols, chrSymbols) + 1)
.join('');
return castSlice(strSymbols, start, end).join('');
}
export default trim;

View File

@@ -1,3 +1,4 @@
import castSlice from './_castSlice';
import charsEndIndex from './_charsEndIndex';
import stringToArray from './_stringToArray';
import toString from './toString';
@@ -32,14 +33,13 @@ function trimEnd(string, chars, guard) {
if (guard || chars === undefined) {
return string.replace(reTrimEnd, '');
}
chars = (chars + '');
if (!chars) {
if (!(chars += '')) {
return string;
}
var strSymbols = stringToArray(string);
return strSymbols
.slice(0, charsEndIndex(strSymbols, stringToArray(chars)) + 1)
.join('');
var strSymbols = stringToArray(string),
end = charsEndIndex(strSymbols, stringToArray(chars)) + 1;
return castSlice(strSymbols, 0, end).join('');
}
export default trimEnd;

View File

@@ -1,3 +1,4 @@
import castSlice from './_castSlice';
import charsStartIndex from './_charsStartIndex';
import stringToArray from './_stringToArray';
import toString from './toString';
@@ -32,14 +33,13 @@ function trimStart(string, chars, guard) {
if (guard || chars === undefined) {
return string.replace(reTrimStart, '');
}
chars = (chars + '');
if (!chars) {
if (!(chars += '')) {
return string;
}
var strSymbols = stringToArray(string);
return strSymbols
.slice(charsStartIndex(strSymbols, stringToArray(chars)))
.join('');
var strSymbols = stringToArray(string),
start = charsStartIndex(strSymbols, stringToArray(chars));
return castSlice(strSymbols, start).join('');
}
export default trimStart;

View File

@@ -1,5 +1,7 @@
import castSlice from './_castSlice';
import isObject from './isObject';
import isRegExp from './isRegExp';
import reHasComplexSymbol from './_reHasComplexSymbol';
import stringSize from './_stringSize';
import stringToArray from './_stringToArray';
import toInteger from './toInteger';
@@ -12,18 +14,6 @@ var DEFAULT_TRUNC_LENGTH = 30,
/** Used to match `RegExp` flags from their coerced string values. */
var reFlags = /\w*$/;
/** Used to compose unicode character classes. */
var rsAstralRange = '\\ud800-\\udfff',
rsComboMarksRange = '\\u0300-\\u036f\\ufe20-\\ufe23',
rsComboSymbolsRange = '\\u20d0-\\u20f0',
rsVarRange = '\\ufe0e\\ufe0f';
/** Used to compose unicode capture groups. */
var rsZWJ = '\\u200d';
/** Used to detect strings with [zero-width joiners or code points from the astral planes](http://eev.ee/blog/2015/09/12/dark-corners-of-unicode/). */
var reHasComplexSymbol = RegExp('[' + rsZWJ + rsAstralRange + rsComboMarksRange + rsComboSymbolsRange + rsVarRange + ']');
/**
* Truncates `string` if it's longer than the given maximum string length.
* The last characters of the truncated string are replaced with the omission
@@ -85,7 +75,7 @@ function truncate(string, options) {
return omission;
}
var result = strSymbols
? strSymbols.slice(0, end).join('')
? castSlice(strSymbols, 0, end).join('')
: string.slice(0, end);
if (separator === undefined) {

View File

@@ -1,5 +1,6 @@
import baseFlatten from './_baseFlatten';
import baseUniq from './_baseUniq';
import isArrayLikeObject from './isArrayLikeObject';
import rest from './rest';
/**
@@ -19,7 +20,7 @@ import rest from './rest';
* // => [2, 1, 4]
*/
var union = rest(function(arrays) {
return baseUniq(baseFlatten(arrays, 1, true));
return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true));
});
export default union;

Some files were not shown because too many files have changed in this diff Show More