mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-06 09:47:48 +00:00
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
692aabae13 | ||
|
|
764eccfdc0 | ||
|
|
f10bb8b80b |
@@ -1,4 +1,4 @@
|
|||||||
# lodash-es v4.9.0
|
# lodash-es v4.11.1
|
||||||
|
|
||||||
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.9.0-es) for more details.
|
See the [package source](https://github.com/lodash/lodash/tree/4.11.1-es) for more details.
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import createBaseFor from './_createBaseFor';
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* The base implementation of `baseForOwn` which iterates over `object`
|
* 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`.
|
* Iteratee functions may exit iteration early by explicitly returning `false`.
|
||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import baseCastPath from './_baseCastPath';
|
import castPath from './_castPath';
|
||||||
import isKey from './_isKey';
|
import isKey from './_isKey';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -10,7 +10,7 @@ import isKey from './_isKey';
|
|||||||
* @returns {*} Returns the resolved value.
|
* @returns {*} Returns the resolved value.
|
||||||
*/
|
*/
|
||||||
function baseGet(object, path) {
|
function baseGet(object, path) {
|
||||||
path = isKey(path, object) ? [path] : baseCastPath(path);
|
path = isKey(path, object) ? [path] : castPath(path);
|
||||||
|
|
||||||
var index = 0,
|
var index = 0,
|
||||||
length = path.length;
|
length = path.length;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import apply from './_apply';
|
import apply from './_apply';
|
||||||
import baseCastPath from './_baseCastPath';
|
import castPath from './_castPath';
|
||||||
import isKey from './_isKey';
|
import isKey from './_isKey';
|
||||||
import last from './last';
|
import last from './last';
|
||||||
import parent from './_parent';
|
import parent from './_parent';
|
||||||
@@ -16,7 +16,7 @@ import parent from './_parent';
|
|||||||
*/
|
*/
|
||||||
function baseInvoke(object, path, args) {
|
function baseInvoke(object, path, args) {
|
||||||
if (!isKey(path, object)) {
|
if (!isKey(path, object)) {
|
||||||
path = baseCastPath(path);
|
path = castPath(path);
|
||||||
object = parent(object, path);
|
object = parent(object, path);
|
||||||
path = last(path);
|
path = last(path);
|
||||||
}
|
}
|
||||||
|
|||||||
20
_baseNth.js
Normal file
20
_baseNth.js
Normal 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;
|
||||||
@@ -2,6 +2,7 @@ import arrayMap from './_arrayMap';
|
|||||||
import baseIteratee from './_baseIteratee';
|
import baseIteratee from './_baseIteratee';
|
||||||
import baseMap from './_baseMap';
|
import baseMap from './_baseMap';
|
||||||
import baseSortBy from './_baseSortBy';
|
import baseSortBy from './_baseSortBy';
|
||||||
|
import baseUnary from './_baseUnary';
|
||||||
import compareMultiple from './_compareMultiple';
|
import compareMultiple from './_compareMultiple';
|
||||||
import identity from './identity';
|
import identity from './identity';
|
||||||
|
|
||||||
@@ -16,7 +17,7 @@ import identity from './identity';
|
|||||||
*/
|
*/
|
||||||
function baseOrderBy(collection, iteratees, orders) {
|
function baseOrderBy(collection, iteratees, orders) {
|
||||||
var index = -1;
|
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 result = baseMap(collection, function(value, key, collection) {
|
||||||
var criteria = arrayMap(iteratees, function(iteratee) {
|
var criteria = arrayMap(iteratees, function(iteratee) {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import baseCastPath from './_baseCastPath';
|
import castPath from './_castPath';
|
||||||
import isIndex from './_isIndex';
|
import isIndex from './_isIndex';
|
||||||
import isKey from './_isKey';
|
import isKey from './_isKey';
|
||||||
import last from './last';
|
import last from './last';
|
||||||
@@ -31,7 +31,7 @@ function basePullAt(array, indexes) {
|
|||||||
splice.call(array, index, 1);
|
splice.call(array, index, 1);
|
||||||
}
|
}
|
||||||
else if (!isKey(index, array)) {
|
else if (!isKey(index, array)) {
|
||||||
var path = baseCastPath(index),
|
var path = castPath(index),
|
||||||
object = parent(array, path);
|
object = parent(array, path);
|
||||||
|
|
||||||
if (object != null) {
|
if (object != null) {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import assignValue from './_assignValue';
|
import assignValue from './_assignValue';
|
||||||
import baseCastPath from './_baseCastPath';
|
import castPath from './_castPath';
|
||||||
import isIndex from './_isIndex';
|
import isIndex from './_isIndex';
|
||||||
import isKey from './_isKey';
|
import isKey from './_isKey';
|
||||||
import isObject from './isObject';
|
import isObject from './isObject';
|
||||||
@@ -15,7 +15,7 @@ import isObject from './isObject';
|
|||||||
* @returns {Object} Returns `object`.
|
* @returns {Object} Returns `object`.
|
||||||
*/
|
*/
|
||||||
function baseSet(object, path, value, customizer) {
|
function baseSet(object, path, value, customizer) {
|
||||||
path = isKey(path, object) ? [path] : baseCastPath(path);
|
path = isKey(path, object) ? [path] : castPath(path);
|
||||||
|
|
||||||
var index = -1,
|
var index = -1,
|
||||||
length = path.length,
|
length = path.length,
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import baseCastPath from './_baseCastPath';
|
import castPath from './_castPath';
|
||||||
import has from './has';
|
import has from './has';
|
||||||
import isKey from './_isKey';
|
import isKey from './_isKey';
|
||||||
import last from './last';
|
import last from './last';
|
||||||
@@ -13,7 +13,7 @@ import parent from './_parent';
|
|||||||
* @returns {boolean} Returns `true` if the property is deleted, else `false`.
|
* @returns {boolean} Returns `true` if the property is deleted, else `false`.
|
||||||
*/
|
*/
|
||||||
function baseUnset(object, path) {
|
function baseUnset(object, path) {
|
||||||
path = isKey(path, object) ? [path] : baseCastPath(path);
|
path = isKey(path, object) ? [path] : castPath(path);
|
||||||
object = parent(object, path);
|
object = parent(object, path);
|
||||||
var key = last(path);
|
var key = last(path);
|
||||||
return (object != null && has(object, key)) ? delete object[key] : true;
|
return (object != null && has(object, key)) ? delete object[key] : true;
|
||||||
|
|||||||
@@ -7,8 +7,8 @@ import isArrayLikeObject from './isArrayLikeObject';
|
|||||||
* @param {*} value The value to inspect.
|
* @param {*} value The value to inspect.
|
||||||
* @returns {Array|Object} Returns the cast array-like object.
|
* @returns {Array|Object} Returns the cast array-like object.
|
||||||
*/
|
*/
|
||||||
function baseCastArrayLikeObject(value) {
|
function castArrayLikeObject(value) {
|
||||||
return isArrayLikeObject(value) ? value : [];
|
return isArrayLikeObject(value) ? value : [];
|
||||||
}
|
}
|
||||||
|
|
||||||
export default baseCastArrayLikeObject;
|
export default castArrayLikeObject;
|
||||||
@@ -7,8 +7,8 @@ import identity from './identity';
|
|||||||
* @param {*} value The value to inspect.
|
* @param {*} value The value to inspect.
|
||||||
* @returns {Function} Returns cast function.
|
* @returns {Function} Returns cast function.
|
||||||
*/
|
*/
|
||||||
function baseCastFunction(value) {
|
function castFunction(value) {
|
||||||
return typeof value == 'function' ? value : identity;
|
return typeof value == 'function' ? value : identity;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default baseCastFunction;
|
export default castFunction;
|
||||||
@@ -8,8 +8,8 @@ import stringToPath from './_stringToPath';
|
|||||||
* @param {*} value The value to inspect.
|
* @param {*} value The value to inspect.
|
||||||
* @returns {Array} Returns the cast property path array.
|
* @returns {Array} Returns the cast property path array.
|
||||||
*/
|
*/
|
||||||
function baseCastPath(value) {
|
function castPath(value) {
|
||||||
return isArray(value) ? value : stringToPath(value);
|
return isArray(value) ? value : stringToPath(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
export default baseCastPath;
|
export default castPath;
|
||||||
18
_castSlice.js
Normal file
18
_castSlice.js
Normal 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;
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
import copyObjectWith from './_copyObjectWith';
|
import assignValue from './_assignValue';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Copies properties of `source` to `object`.
|
* Copies properties of `source` to `object`.
|
||||||
@@ -7,10 +7,25 @@ import copyObjectWith from './_copyObjectWith';
|
|||||||
* @param {Object} source The object to copy properties from.
|
* @param {Object} source The object to copy properties from.
|
||||||
* @param {Array} props The property identifiers to copy.
|
* @param {Array} props The property identifiers to copy.
|
||||||
* @param {Object} [object={}] The object to copy properties to.
|
* @param {Object} [object={}] The object to copy properties to.
|
||||||
|
* @param {Function} [customizer] The function to customize copied values.
|
||||||
* @returns {Object} Returns `object`.
|
* @returns {Object} Returns `object`.
|
||||||
*/
|
*/
|
||||||
function copyObject(source, props, object) {
|
function copyObject(source, props, object, customizer) {
|
||||||
return copyObjectWith(source, props, object);
|
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;
|
export default copyObject;
|
||||||
|
|||||||
@@ -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;
|
|
||||||
@@ -1,18 +1,8 @@
|
|||||||
|
import castSlice from './_castSlice';
|
||||||
|
import reHasComplexSymbol from './_reHasComplexSymbol';
|
||||||
import stringToArray from './_stringToArray';
|
import stringToArray from './_stringToArray';
|
||||||
import toString from './toString';
|
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`.
|
* Creates a function like `_.lowerFirst`.
|
||||||
*
|
*
|
||||||
@@ -28,8 +18,13 @@ function createCaseFirst(methodName) {
|
|||||||
? stringToArray(string)
|
? stringToArray(string)
|
||||||
: undefined;
|
: undefined;
|
||||||
|
|
||||||
var chr = strSymbols ? strSymbols[0] : string.charAt(0),
|
var chr = strSymbols
|
||||||
trailing = strSymbols ? strSymbols.slice(1).join('') : string.slice(1);
|
? strSymbols[0]
|
||||||
|
: string.charAt(0);
|
||||||
|
|
||||||
|
var trailing = strSymbols
|
||||||
|
? castSlice(strSymbols, 1).join('')
|
||||||
|
: string.slice(1);
|
||||||
|
|
||||||
return chr[methodName]() + trailing;
|
return chr[methodName]() + trailing;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -2,6 +2,12 @@ import arrayReduce from './_arrayReduce';
|
|||||||
import deburr from './deburr';
|
import deburr from './deburr';
|
||||||
import words from './words';
|
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`.
|
* Creates a function like `_.camelCase`.
|
||||||
*
|
*
|
||||||
@@ -11,7 +17,7 @@ import words from './words';
|
|||||||
*/
|
*/
|
||||||
function createCompounder(callback) {
|
function createCompounder(callback) {
|
||||||
return function(string) {
|
return function(string) {
|
||||||
return arrayReduce(words(deburr(string)), callback, '');
|
return arrayReduce(words(deburr(string).replace(reApos, '')), callback, '');
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,8 @@ import apply from './_apply';
|
|||||||
import arrayMap from './_arrayMap';
|
import arrayMap from './_arrayMap';
|
||||||
import baseFlatten from './_baseFlatten';
|
import baseFlatten from './_baseFlatten';
|
||||||
import baseIteratee from './_baseIteratee';
|
import baseIteratee from './_baseIteratee';
|
||||||
|
import baseUnary from './_baseUnary';
|
||||||
|
import isArray from './isArray';
|
||||||
import isFlattenableIteratee from './_isFlattenableIteratee';
|
import isFlattenableIteratee from './_isFlattenableIteratee';
|
||||||
import rest from './rest';
|
import rest from './rest';
|
||||||
|
|
||||||
@@ -14,7 +16,10 @@ import rest from './rest';
|
|||||||
*/
|
*/
|
||||||
function createOver(arrayFunc) {
|
function createOver(arrayFunc) {
|
||||||
return rest(function(iteratees) {
|
return rest(function(iteratees) {
|
||||||
iteratees = arrayMap(baseFlatten(iteratees, 1, isFlattenableIteratee), baseIteratee);
|
iteratees = (iteratees.length == 1 && isArray(iteratees[0]))
|
||||||
|
? arrayMap(iteratees[0], baseUnary(baseIteratee))
|
||||||
|
: arrayMap(baseFlatten(iteratees, 1, isFlattenableIteratee), baseUnary(baseIteratee));
|
||||||
|
|
||||||
return rest(function(args) {
|
return rest(function(args) {
|
||||||
var thisArg = this;
|
var thisArg = this;
|
||||||
return arrayFunc(iteratees, function(iteratee) {
|
return arrayFunc(iteratees, function(iteratee) {
|
||||||
|
|||||||
@@ -1,19 +1,9 @@
|
|||||||
import baseRepeat from './_baseRepeat';
|
import baseRepeat from './_baseRepeat';
|
||||||
|
import castSlice from './_castSlice';
|
||||||
|
import reHasComplexSymbol from './_reHasComplexSymbol';
|
||||||
import stringSize from './_stringSize';
|
import stringSize from './_stringSize';
|
||||||
import stringToArray from './_stringToArray';
|
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. */
|
/* Built-in method references for those with the same name as other `lodash` methods. */
|
||||||
var nativeCeil = Math.ceil;
|
var nativeCeil = Math.ceil;
|
||||||
|
|
||||||
@@ -35,7 +25,7 @@ function createPadding(length, chars) {
|
|||||||
}
|
}
|
||||||
var result = baseRepeat(chars, nativeCeil(length / stringSize(chars)));
|
var result = baseRepeat(chars, nativeCeil(length / stringSize(chars)));
|
||||||
return reHasComplexSymbol.test(chars)
|
return reHasComplexSymbol.test(chars)
|
||||||
? stringToArray(result).slice(0, length).join('')
|
? castSlice(stringToArray(result), 0, length).join('')
|
||||||
: result.slice(0, length);
|
: result.slice(0, length);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import copyArray from './_copyArray';
|
|
||||||
import isLaziable from './_isLaziable';
|
import isLaziable from './_isLaziable';
|
||||||
import setData from './_setData';
|
import setData from './_setData';
|
||||||
|
|
||||||
@@ -30,7 +29,6 @@ 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,
|
|
||||||
newHolders = isCurry ? holders : undefined,
|
newHolders = isCurry ? holders : undefined,
|
||||||
newHoldersRight = isCurry ? undefined : holders,
|
newHoldersRight = isCurry ? undefined : holders,
|
||||||
newPartials = isCurry ? partials : undefined,
|
newPartials = isCurry ? partials : undefined,
|
||||||
@@ -44,7 +42,7 @@ function createRecurryWrapper(func, bitmask, wrapFunc, placeholder, thisArg, par
|
|||||||
}
|
}
|
||||||
var newData = [
|
var newData = [
|
||||||
func, bitmask, thisArg, newPartials, newHolders, newPartialsRight,
|
func, bitmask, thisArg, newPartials, newHolders, newPartialsRight,
|
||||||
newHoldersRight, newArgPos, ary, arity
|
newHoldersRight, argPos, ary, arity
|
||||||
];
|
];
|
||||||
|
|
||||||
var result = wrapFunc.apply(undefined, newData);
|
var result = wrapFunc.apply(undefined, newData);
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import baseCastPath from './_baseCastPath';
|
import castPath from './_castPath';
|
||||||
import isArguments from './isArguments';
|
import isArguments from './isArguments';
|
||||||
import isArray from './isArray';
|
import isArray from './isArray';
|
||||||
import isIndex from './_isIndex';
|
import isIndex from './_isIndex';
|
||||||
@@ -16,7 +16,7 @@ import isString from './isString';
|
|||||||
* @returns {boolean} Returns `true` if `path` exists, else `false`.
|
* @returns {boolean} Returns `true` if `path` exists, else `false`.
|
||||||
*/
|
*/
|
||||||
function hasPath(object, path, hasFunc) {
|
function hasPath(object, path, hasFunc) {
|
||||||
path = isKey(path, object) ? [path] : baseCastPath(path);
|
path = isKey(path, object) ? [path] : castPath(path);
|
||||||
|
|
||||||
var result,
|
var result,
|
||||||
index = -1,
|
index = -1,
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import composeArgs from './_composeArgs';
|
import composeArgs from './_composeArgs';
|
||||||
import composeArgsRight from './_composeArgsRight';
|
import composeArgsRight from './_composeArgsRight';
|
||||||
import copyArray from './_copyArray';
|
|
||||||
import replaceHolders from './_replaceHolders';
|
import replaceHolders from './_replaceHolders';
|
||||||
|
|
||||||
/** Used as the internal argument placeholder. */
|
/** Used as the internal argument placeholder. */
|
||||||
@@ -58,20 +57,20 @@ function mergeData(data, source) {
|
|||||||
var value = source[3];
|
var value = source[3];
|
||||||
if (value) {
|
if (value) {
|
||||||
var partials = data[3];
|
var partials = data[3];
|
||||||
data[3] = partials ? composeArgs(partials, value, source[4]) : copyArray(value);
|
data[3] = partials ? composeArgs(partials, value, source[4]) : value;
|
||||||
data[4] = partials ? replaceHolders(data[3], PLACEHOLDER) : copyArray(source[4]);
|
data[4] = partials ? replaceHolders(data[3], PLACEHOLDER) : source[4];
|
||||||
}
|
}
|
||||||
// Compose partial right arguments.
|
// Compose partial right arguments.
|
||||||
value = source[5];
|
value = source[5];
|
||||||
if (value) {
|
if (value) {
|
||||||
partials = data[5];
|
partials = data[5];
|
||||||
data[5] = partials ? composeArgsRight(partials, value, source[6]) : copyArray(value);
|
data[5] = partials ? composeArgsRight(partials, value, source[6]) : value;
|
||||||
data[6] = partials ? replaceHolders(data[5], PLACEHOLDER) : copyArray(source[6]);
|
data[6] = partials ? replaceHolders(data[5], PLACEHOLDER) : source[6];
|
||||||
}
|
}
|
||||||
// Use source `argPos` if available.
|
// Use source `argPos` if available.
|
||||||
value = source[7];
|
value = source[7];
|
||||||
if (value) {
|
if (value) {
|
||||||
data[7] = copyArray(value);
|
data[7] = value;
|
||||||
}
|
}
|
||||||
// Use source `ary` if it's smaller.
|
// Use source `ary` if it's smaller.
|
||||||
if (srcBitmask & ARY_FLAG) {
|
if (srcBitmask & ARY_FLAG) {
|
||||||
|
|||||||
13
_reHasComplexSymbol.js
Normal file
13
_reHasComplexSymbol.js
Normal 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;
|
||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import reHasComplexSymbol from './_reHasComplexSymbol';
|
||||||
|
|
||||||
/** Used to compose unicode character classes. */
|
/** Used to compose unicode character classes. */
|
||||||
var rsAstralRange = '\\ud800-\\udfff',
|
var rsAstralRange = '\\ud800-\\udfff',
|
||||||
rsComboMarksRange = '\\u0300-\\u036f\\ufe20-\\ufe23',
|
rsComboMarksRange = '\\u0300-\\u036f\\ufe20-\\ufe23',
|
||||||
@@ -24,9 +26,6 @@ var reOptMod = rsModifier + '?',
|
|||||||
/** Used to match [string symbols](https://mathiasbynens.be/notes/javascript-unicode). */
|
/** Used to match [string symbols](https://mathiasbynens.be/notes/javascript-unicode). */
|
||||||
var reComplexSymbol = RegExp(rsFitz + '(?=' + rsFitz + ')|' + rsSymbol + rsSeq, 'g');
|
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`.
|
* Gets the number of symbols in `string`.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -1,14 +1,14 @@
|
|||||||
import isSymbol from './isSymbol';
|
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
|
* @private
|
||||||
* @param {*} value The value to inspect.
|
* @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 + '');
|
return (typeof key == 'string' || isSymbol(key)) ? key : (key + '');
|
||||||
}
|
}
|
||||||
|
|
||||||
export default baseCastKey;
|
export default toKey;
|
||||||
@@ -24,6 +24,7 @@ import intersectionWith from './intersectionWith';
|
|||||||
import join from './join';
|
import join from './join';
|
||||||
import last from './last';
|
import last from './last';
|
||||||
import lastIndexOf from './lastIndexOf';
|
import lastIndexOf from './lastIndexOf';
|
||||||
|
import nth from './nth';
|
||||||
import pull from './pull';
|
import pull from './pull';
|
||||||
import pullAll from './pullAll';
|
import pullAll from './pullAll';
|
||||||
import pullAllBy from './pullAllBy';
|
import pullAllBy from './pullAllBy';
|
||||||
@@ -68,12 +69,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, pullAllWith,
|
lastIndexOf, nth, pull, pullAll, pullAllBy,
|
||||||
pullAt, remove, reverse, slice, sortedIndex,
|
pullAllWith, pullAt, remove, reverse, slice,
|
||||||
sortedIndexBy, sortedIndexOf, sortedLastIndex, sortedLastIndexBy, sortedLastIndexOf,
|
sortedIndex, sortedIndexBy, sortedIndexOf, sortedLastIndex, sortedLastIndexBy,
|
||||||
sortedUniq, sortedUniqBy, tail, take, takeRight,
|
sortedLastIndexOf, sortedUniq, sortedUniqBy, tail, take,
|
||||||
takeRightWhile, takeWhile, union, unionBy, unionWith,
|
takeRight, takeRightWhile, takeWhile, union, unionBy,
|
||||||
uniq, uniqBy, uniqWith, unzip, unzipWith,
|
unionWith, uniq, uniqBy, uniqWith, unzip,
|
||||||
without, xor, xorBy, xorWith, zip,
|
unzipWith, without, xor, xorBy, xorWith,
|
||||||
zipObject, zipObjectDeep, zipWith
|
zip, zipObject, zipObjectDeep, zipWith
|
||||||
};
|
};
|
||||||
|
|||||||
1
array.js
1
array.js
@@ -24,6 +24,7 @@ export { default as intersectionWith } from './intersectionWith';
|
|||||||
export { default as join } from './join';
|
export { default as join } from './join';
|
||||||
export { default as last } from './last';
|
export { default as last } from './last';
|
||||||
export { default as lastIndexOf } from './lastIndexOf';
|
export { default as lastIndexOf } from './lastIndexOf';
|
||||||
|
export { default as nth } from './nth';
|
||||||
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';
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import copyObjectWith from './_copyObjectWith';
|
import copyObject from './_copyObject';
|
||||||
import createAssigner from './_createAssigner';
|
import createAssigner from './_createAssigner';
|
||||||
import keysIn from './keysIn';
|
import keysIn from './keysIn';
|
||||||
|
|
||||||
@@ -31,7 +31,7 @@ import keysIn from './keysIn';
|
|||||||
* // => { 'a': 1, 'b': 2 }
|
* // => { 'a': 1, 'b': 2 }
|
||||||
*/
|
*/
|
||||||
var assignInWith = createAssigner(function(object, source, srcIndex, customizer) {
|
var assignInWith = createAssigner(function(object, source, srcIndex, customizer) {
|
||||||
copyObjectWith(source, keysIn(source), object, customizer);
|
copyObject(source, keysIn(source), object, customizer);
|
||||||
});
|
});
|
||||||
|
|
||||||
export default assignInWith;
|
export default assignInWith;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import copyObjectWith from './_copyObjectWith';
|
import copyObject from './_copyObject';
|
||||||
import createAssigner from './_createAssigner';
|
import createAssigner from './_createAssigner';
|
||||||
import keys from './keys';
|
import keys from './keys';
|
||||||
|
|
||||||
@@ -30,7 +30,7 @@ import keys from './keys';
|
|||||||
* // => { 'a': 1, 'b': 2 }
|
* // => { 'a': 1, 'b': 2 }
|
||||||
*/
|
*/
|
||||||
var assignWith = createAssigner(function(object, source, srcIndex, customizer) {
|
var assignWith = createAssigner(function(object, source, srcIndex, customizer) {
|
||||||
copyObjectWith(source, keys(source), object, customizer);
|
copyObject(source, keys(source), object, customizer);
|
||||||
});
|
});
|
||||||
|
|
||||||
export default assignWith;
|
export default assignWith;
|
||||||
|
|||||||
3
at.js
3
at.js
@@ -10,8 +10,7 @@ import rest from './rest';
|
|||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
* @category Object
|
* @category Object
|
||||||
* @param {Object} object The object to iterate over.
|
* @param {Object} object The object to iterate over.
|
||||||
* @param {...(string|string[])} [paths] The property paths of elements to pick,
|
* @param {...(string|string[])} [paths] The property paths of elements to pick.
|
||||||
* specified individually or in arrays.
|
|
||||||
* @returns {Array} Returns the new array of picked elements.
|
* @returns {Array} Returns the new array of picked elements.
|
||||||
* @example
|
* @example
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -14,8 +14,7 @@ import rest from './rest';
|
|||||||
* @memberOf _
|
* @memberOf _
|
||||||
* @category Util
|
* @category Util
|
||||||
* @param {Object} object The object to bind and assign the bound methods to.
|
* @param {Object} object The object to bind and assign the bound methods to.
|
||||||
* @param {...(string|string[])} methodNames The object method names to bind,
|
* @param {...(string|string[])} methodNames The object method names to bind.
|
||||||
* specified individually or in arrays.
|
|
||||||
* @returns {Object} Returns `object`.
|
* @returns {Object} Returns `object`.
|
||||||
* @example
|
* @example
|
||||||
*
|
*
|
||||||
|
|||||||
2
cond.js
2
cond.js
@@ -7,7 +7,7 @@ import rest from './rest';
|
|||||||
var FUNC_ERROR_TEXT = 'Expected a function';
|
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
|
* function of the first predicate to return truthy. The predicate-function
|
||||||
* pairs are invoked with the `this` binding and arguments of the created
|
* pairs are invoked with the `this` binding and arguments of the created
|
||||||
* function.
|
* function.
|
||||||
|
|||||||
21
debounce.js
21
debounce.js
@@ -62,12 +62,13 @@ var nativeMax = Math.max,
|
|||||||
function debounce(func, wait, options) {
|
function debounce(func, wait, options) {
|
||||||
var lastArgs,
|
var lastArgs,
|
||||||
lastThis,
|
lastThis,
|
||||||
|
maxWait,
|
||||||
result,
|
result,
|
||||||
timerId,
|
timerId,
|
||||||
lastCallTime = 0,
|
lastCallTime = 0,
|
||||||
lastInvokeTime = 0,
|
lastInvokeTime = 0,
|
||||||
leading = false,
|
leading = false,
|
||||||
maxWait = false,
|
maxing = false,
|
||||||
trailing = true;
|
trailing = true;
|
||||||
|
|
||||||
if (typeof func != 'function') {
|
if (typeof func != 'function') {
|
||||||
@@ -76,7 +77,8 @@ function debounce(func, wait, options) {
|
|||||||
wait = toNumber(wait) || 0;
|
wait = toNumber(wait) || 0;
|
||||||
if (isObject(options)) {
|
if (isObject(options)) {
|
||||||
leading = !!options.leading;
|
leading = !!options.leading;
|
||||||
maxWait = 'maxWait' in options && nativeMax(toNumber(options.maxWait) || 0, wait);
|
maxing = 'maxWait' in options;
|
||||||
|
maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait;
|
||||||
trailing = 'trailing' in options ? !!options.trailing : trailing;
|
trailing = 'trailing' in options ? !!options.trailing : trailing;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -104,7 +106,7 @@ function debounce(func, wait, options) {
|
|||||||
timeSinceLastInvoke = time - lastInvokeTime,
|
timeSinceLastInvoke = time - lastInvokeTime,
|
||||||
result = wait - timeSinceLastCall;
|
result = wait - timeSinceLastCall;
|
||||||
|
|
||||||
return maxWait === false ? result : nativeMin(result, maxWait - timeSinceLastInvoke);
|
return maxing ? nativeMin(result, maxWait - timeSinceLastInvoke) : result;
|
||||||
}
|
}
|
||||||
|
|
||||||
function shouldInvoke(time) {
|
function shouldInvoke(time) {
|
||||||
@@ -115,7 +117,7 @@ function debounce(func, wait, options) {
|
|||||||
// trailing edge, the system time has gone backwards and we're treating
|
// trailing edge, the system time has gone backwards and we're treating
|
||||||
// it as the trailing edge, or we've hit the `maxWait` limit.
|
// it as the trailing edge, or we've hit the `maxWait` limit.
|
||||||
return (!lastCallTime || (timeSinceLastCall >= wait) ||
|
return (!lastCallTime || (timeSinceLastCall >= wait) ||
|
||||||
(timeSinceLastCall < 0) || (maxWait !== false && timeSinceLastInvoke >= maxWait));
|
(timeSinceLastCall < 0) || (maxing && timeSinceLastInvoke >= maxWait));
|
||||||
}
|
}
|
||||||
|
|
||||||
function timerExpired() {
|
function timerExpired() {
|
||||||
@@ -164,10 +166,15 @@ function debounce(func, wait, options) {
|
|||||||
if (timerId === undefined) {
|
if (timerId === undefined) {
|
||||||
return leadingEdge(lastCallTime);
|
return leadingEdge(lastCallTime);
|
||||||
}
|
}
|
||||||
// Handle invocations in a tight loop.
|
if (maxing) {
|
||||||
clearTimeout(timerId);
|
// Handle invocations in a tight loop.
|
||||||
|
clearTimeout(timerId);
|
||||||
|
timerId = setTimeout(timerExpired, wait);
|
||||||
|
return invokeFunc(lastCallTime);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (timerId === undefined) {
|
||||||
timerId = setTimeout(timerExpired, wait);
|
timerId = setTimeout(timerExpired, wait);
|
||||||
return invokeFunc(lastCallTime);
|
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import baseIteratee from './_baseIteratee';
|
|||||||
import isArray from './isArray';
|
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).
|
* The iteratee is invoked with three arguments: (value, index|key, collection).
|
||||||
* Iteratee functions may exit iteration early by explicitly returning `false`.
|
* Iteratee functions may exit iteration early by explicitly returning `false`.
|
||||||
*
|
*
|
||||||
|
|||||||
6
forIn.js
6
forIn.js
@@ -4,9 +4,9 @@ import keysIn from './keysIn';
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Iterates over own and inherited enumerable string keyed properties of an
|
* Iterates over own and inherited enumerable string keyed properties of an
|
||||||
* object invoking `iteratee` for each property. The iteratee is invoked with
|
* object and invokes `iteratee` for each property. The iteratee is invoked
|
||||||
* three arguments: (value, key, object). Iteratee functions may exit iteration
|
* with three arguments: (value, key, object). Iteratee functions may exit
|
||||||
* early by explicitly returning `false`.
|
* iteration early by explicitly returning `false`.
|
||||||
*
|
*
|
||||||
* @static
|
* @static
|
||||||
* @memberOf _
|
* @memberOf _
|
||||||
|
|||||||
@@ -2,10 +2,10 @@ import baseForOwn from './_baseForOwn';
|
|||||||
import baseIteratee from './_baseIteratee';
|
import baseIteratee from './_baseIteratee';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Iterates over own enumerable string keyed properties of an object invoking
|
* Iterates over own enumerable string keyed properties of an object and
|
||||||
* `iteratee` for each property. The iteratee is invoked with three arguments:
|
* invokes `iteratee` for each property. The iteratee is invoked with three
|
||||||
* (value, key, object). Iteratee functions may exit iteration early by
|
* arguments: (value, key, object). Iteratee functions may exit iteration
|
||||||
* explicitly returning `false`.
|
* early by explicitly returning `false`.
|
||||||
*
|
*
|
||||||
* @static
|
* @static
|
||||||
* @memberOf _
|
* @memberOf _
|
||||||
|
|||||||
2
head.js
2
head.js
@@ -17,7 +17,7 @@
|
|||||||
* // => undefined
|
* // => undefined
|
||||||
*/
|
*/
|
||||||
function head(array) {
|
function head(array) {
|
||||||
return array ? array[0] : undefined;
|
return (array && array.length) ? array[0] : undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default head;
|
export default head;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import arrayMap from './_arrayMap';
|
import arrayMap from './_arrayMap';
|
||||||
import baseCastArrayLikeObject from './_baseCastArrayLikeObject';
|
|
||||||
import baseIntersection from './_baseIntersection';
|
import baseIntersection from './_baseIntersection';
|
||||||
|
import castArrayLikeObject from './_castArrayLikeObject';
|
||||||
import rest from './rest';
|
import rest from './rest';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -21,7 +21,7 @@ import rest from './rest';
|
|||||||
* // => [2]
|
* // => [2]
|
||||||
*/
|
*/
|
||||||
var intersection = rest(function(arrays) {
|
var intersection = rest(function(arrays) {
|
||||||
var mapped = arrayMap(arrays, baseCastArrayLikeObject);
|
var mapped = arrayMap(arrays, castArrayLikeObject);
|
||||||
return (mapped.length && mapped[0] === arrays[0])
|
return (mapped.length && mapped[0] === arrays[0])
|
||||||
? baseIntersection(mapped)
|
? baseIntersection(mapped)
|
||||||
: [];
|
: [];
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import arrayMap from './_arrayMap';
|
import arrayMap from './_arrayMap';
|
||||||
import baseCastArrayLikeObject from './_baseCastArrayLikeObject';
|
|
||||||
import baseIntersection from './_baseIntersection';
|
import baseIntersection from './_baseIntersection';
|
||||||
import baseIteratee from './_baseIteratee';
|
import baseIteratee from './_baseIteratee';
|
||||||
|
import castArrayLikeObject from './_castArrayLikeObject';
|
||||||
import last from './last';
|
import last from './last';
|
||||||
import rest from './rest';
|
import rest from './rest';
|
||||||
|
|
||||||
@@ -30,7 +30,7 @@ import rest from './rest';
|
|||||||
*/
|
*/
|
||||||
var intersectionBy = rest(function(arrays) {
|
var intersectionBy = rest(function(arrays) {
|
||||||
var iteratee = last(arrays),
|
var iteratee = last(arrays),
|
||||||
mapped = arrayMap(arrays, baseCastArrayLikeObject);
|
mapped = arrayMap(arrays, castArrayLikeObject);
|
||||||
|
|
||||||
if (iteratee === last(mapped)) {
|
if (iteratee === last(mapped)) {
|
||||||
iteratee = undefined;
|
iteratee = undefined;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import arrayMap from './_arrayMap';
|
import arrayMap from './_arrayMap';
|
||||||
import baseCastArrayLikeObject from './_baseCastArrayLikeObject';
|
|
||||||
import baseIntersection from './_baseIntersection';
|
import baseIntersection from './_baseIntersection';
|
||||||
|
import castArrayLikeObject from './_castArrayLikeObject';
|
||||||
import last from './last';
|
import last from './last';
|
||||||
import rest from './rest';
|
import rest from './rest';
|
||||||
|
|
||||||
@@ -27,7 +27,7 @@ import rest from './rest';
|
|||||||
*/
|
*/
|
||||||
var intersectionWith = rest(function(arrays) {
|
var intersectionWith = rest(function(arrays) {
|
||||||
var comparator = last(arrays),
|
var comparator = last(arrays),
|
||||||
mapped = arrayMap(arrays, baseCastArrayLikeObject);
|
mapped = arrayMap(arrays, castArrayLikeObject);
|
||||||
|
|
||||||
if (comparator === last(mapped)) {
|
if (comparator === last(mapped)) {
|
||||||
comparator = undefined;
|
comparator = undefined;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* @license
|
* @license
|
||||||
* lodash 4.9.0 (Custom Build) <https://lodash.com/>
|
* lodash 4.11.1 (Custom Build) <https://lodash.com/>
|
||||||
* Build: `lodash modularize exports="es" -o ./`
|
* Build: `lodash modularize exports="es" -o ./`
|
||||||
* Copyright jQuery Foundation and other contributors <https://jquery.org/>
|
* Copyright jQuery Foundation and other contributors <https://jquery.org/>
|
||||||
* Released under MIT license <https://lodash.com/license>
|
* Released under MIT license <https://lodash.com/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.9.0';
|
var VERSION = '4.11.1';
|
||||||
|
|
||||||
/** Used to compose bitmasks for wrapper metadata. */
|
/** Used to compose bitmasks for wrapper metadata. */
|
||||||
var BIND_KEY_FLAG = 2;
|
var BIND_KEY_FLAG = 2;
|
||||||
@@ -342,6 +342,7 @@ lodash.meanBy = math.meanBy;
|
|||||||
lodash.min = math.min;
|
lodash.min = math.min;
|
||||||
lodash.minBy = math.minBy;
|
lodash.minBy = math.minBy;
|
||||||
lodash.multiply = math.multiply;
|
lodash.multiply = math.multiply;
|
||||||
|
lodash.nth = array.nth;
|
||||||
lodash.noop = util.noop;
|
lodash.noop = util.noop;
|
||||||
lodash.now = date.now;
|
lodash.now = date.now;
|
||||||
lodash.pad = string.pad;
|
lodash.pad = string.pad;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* @license
|
* @license
|
||||||
* lodash 4.9.0 (Custom Build) <https://lodash.com/>
|
* lodash 4.11.1 (Custom Build) <https://lodash.com/>
|
||||||
* Build: `lodash modularize exports="es" -o ./`
|
* Build: `lodash modularize exports="es" -o ./`
|
||||||
* Copyright jQuery Foundation and other contributors <https://jquery.org/>
|
* Copyright jQuery Foundation and other contributors <https://jquery.org/>
|
||||||
* Released under MIT license <https://lodash.com/license>
|
* 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 next } from './next';
|
||||||
export { default as noop } from './noop';
|
export { default as noop } from './noop';
|
||||||
export { default as now } from './now';
|
export { default as now } from './now';
|
||||||
|
export { default as nth } from './nth';
|
||||||
export { default as nthArg } from './nthArg';
|
export { default as nthArg } from './nthArg';
|
||||||
export { default as omit } from './omit';
|
export { default as omit } from './omit';
|
||||||
export { default as omitBy } from './omitBy';
|
export { default as omitBy } from './omitBy';
|
||||||
|
|||||||
4
map.js
4
map.js
@@ -14,8 +14,8 @@ import isArray from './isArray';
|
|||||||
* The guarded methods are:
|
* The guarded methods are:
|
||||||
* `ary`, `chunk`, `curry`, `curryRight`, `drop`, `dropRight`, `every`,
|
* `ary`, `chunk`, `curry`, `curryRight`, `drop`, `dropRight`, `every`,
|
||||||
* `fill`, `invert`, `parseInt`, `random`, `range`, `rangeRight`, `repeat`,
|
* `fill`, `invert`, `parseInt`, `random`, `range`, `rangeRight`, `repeat`,
|
||||||
* `sampleSize`, `slice`, `some`, `sortBy`, `take`, `takeRight`, `template`,
|
* `sampleSize`, `slice`, `some`, `sortBy`, `split`, `take`, `takeRight`,
|
||||||
* `trim`, `trimEnd`, `trimStart`, and `words`
|
* `template`, `trim`, `trimEnd`, `trimStart`, and `words`
|
||||||
*
|
*
|
||||||
* @static
|
* @static
|
||||||
* @memberOf _
|
* @memberOf _
|
||||||
|
|||||||
2
mixin.js
2
mixin.js
@@ -46,7 +46,7 @@ function mixin(object, source, options) {
|
|||||||
var props = keys(source),
|
var props = keys(source),
|
||||||
methodNames = baseFunctions(source, props);
|
methodNames = baseFunctions(source, props);
|
||||||
|
|
||||||
var chain = (isObject(options) && 'chain' in options) ? options.chain : true,
|
var chain = !(isObject(options) && 'chain' in options) || !!options.chain,
|
||||||
isFunc = isFunction(object);
|
isFunc = isFunction(object);
|
||||||
|
|
||||||
arrayEach(methodNames, function(methodName) {
|
arrayEach(methodNames, function(methodName) {
|
||||||
|
|||||||
29
nth.js
Normal file
29
nth.js
Normal 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;
|
||||||
18
nthArg.js
18
nthArg.js
@@ -1,7 +1,10 @@
|
|||||||
|
import baseNth from './_baseNth';
|
||||||
|
import rest from './rest';
|
||||||
import toInteger from './toInteger';
|
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
|
* @static
|
||||||
* @memberOf _
|
* @memberOf _
|
||||||
@@ -12,15 +15,18 @@ import toInteger from './toInteger';
|
|||||||
* @example
|
* @example
|
||||||
*
|
*
|
||||||
* var func = _.nthArg(1);
|
* var func = _.nthArg(1);
|
||||||
*
|
* func('a', 'b', 'c', 'd');
|
||||||
* func('a', 'b', 'c');
|
|
||||||
* // => 'b'
|
* // => 'b'
|
||||||
|
*
|
||||||
|
* var func = _.nthArg(-2);
|
||||||
|
* func('a', 'b', 'c', 'd');
|
||||||
|
* // => 'c'
|
||||||
*/
|
*/
|
||||||
function nthArg(n) {
|
function nthArg(n) {
|
||||||
n = toInteger(n);
|
n = toInteger(n);
|
||||||
return function() {
|
return rest(function(args) {
|
||||||
return arguments[n];
|
return baseNth(args, n);
|
||||||
};
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export default nthArg;
|
export default nthArg;
|
||||||
|
|||||||
7
omit.js
7
omit.js
@@ -1,10 +1,10 @@
|
|||||||
import arrayMap from './_arrayMap';
|
import arrayMap from './_arrayMap';
|
||||||
import baseCastKey from './_baseCastKey';
|
|
||||||
import baseDifference from './_baseDifference';
|
import baseDifference from './_baseDifference';
|
||||||
import baseFlatten from './_baseFlatten';
|
import baseFlatten from './_baseFlatten';
|
||||||
import basePick from './_basePick';
|
import basePick from './_basePick';
|
||||||
import getAllKeysIn from './_getAllKeysIn';
|
import getAllKeysIn from './_getAllKeysIn';
|
||||||
import rest from './rest';
|
import rest from './rest';
|
||||||
|
import toKey from './_toKey';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The opposite of `_.pick`; this method creates an object composed of the
|
* The opposite of `_.pick`; this method creates an object composed of the
|
||||||
@@ -16,8 +16,7 @@ import rest from './rest';
|
|||||||
* @memberOf _
|
* @memberOf _
|
||||||
* @category Object
|
* @category Object
|
||||||
* @param {Object} object The source object.
|
* @param {Object} object The source object.
|
||||||
* @param {...(string|string[])} [props] The property identifiers to omit,
|
* @param {...(string|string[])} [props] The property identifiers to omit.
|
||||||
* specified individually or in arrays.
|
|
||||||
* @returns {Object} Returns the new object.
|
* @returns {Object} Returns the new object.
|
||||||
* @example
|
* @example
|
||||||
*
|
*
|
||||||
@@ -30,7 +29,7 @@ var omit = rest(function(object, props) {
|
|||||||
if (object == null) {
|
if (object == null) {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
props = arrayMap(baseFlatten(props, 1), baseCastKey);
|
props = arrayMap(baseFlatten(props, 1), toKey);
|
||||||
return basePick(object, baseDifference(getAllKeysIn(object), props));
|
return basePick(object, baseDifference(getAllKeysIn(object), props));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
3
over.js
3
over.js
@@ -9,7 +9,8 @@ import createOver from './_createOver';
|
|||||||
* @memberOf _
|
* @memberOf _
|
||||||
* @since 4.0.0
|
* @since 4.0.0
|
||||||
* @category Util
|
* @category Util
|
||||||
* @param {...(Function|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.
|
* @returns {Function} Returns the new function.
|
||||||
* @example
|
* @example
|
||||||
*
|
*
|
||||||
|
|||||||
11
overArgs.js
11
overArgs.js
@@ -2,6 +2,8 @@ import apply from './_apply';
|
|||||||
import arrayMap from './_arrayMap';
|
import arrayMap from './_arrayMap';
|
||||||
import baseFlatten from './_baseFlatten';
|
import baseFlatten from './_baseFlatten';
|
||||||
import baseIteratee from './_baseIteratee';
|
import baseIteratee from './_baseIteratee';
|
||||||
|
import baseUnary from './_baseUnary';
|
||||||
|
import isArray from './isArray';
|
||||||
import isFlattenableIteratee from './_isFlattenableIteratee';
|
import isFlattenableIteratee from './_isFlattenableIteratee';
|
||||||
import rest from './rest';
|
import rest from './rest';
|
||||||
|
|
||||||
@@ -17,8 +19,8 @@ var nativeMin = Math.min;
|
|||||||
* @memberOf _
|
* @memberOf _
|
||||||
* @category Function
|
* @category Function
|
||||||
* @param {Function} func The function to wrap.
|
* @param {Function} func The function to wrap.
|
||||||
* @param {...(Function|Function[])} [transforms] The functions to transform.
|
* @param {...(Array|Array[]|Function|Function[]|Object|Object[]|string|string[])}
|
||||||
* arguments, specified individually or in arrays.
|
* [transforms[_.identity]] The functions to transform.
|
||||||
* @returns {Function} Returns the new function.
|
* @returns {Function} Returns the new function.
|
||||||
* @example
|
* @example
|
||||||
*
|
*
|
||||||
@@ -41,7 +43,10 @@ var nativeMin = Math.min;
|
|||||||
* // => [100, 10]
|
* // => [100, 10]
|
||||||
*/
|
*/
|
||||||
var overArgs = rest(function(func, transforms) {
|
var overArgs = rest(function(func, transforms) {
|
||||||
transforms = arrayMap(baseFlatten(transforms, 1, isFlattenableIteratee), baseIteratee);
|
transforms = (transforms.length == 1 && isArray(transforms[0]))
|
||||||
|
? arrayMap(transforms[0], baseUnary(baseIteratee))
|
||||||
|
: arrayMap(baseFlatten(transforms, 1, isFlattenableIteratee), baseUnary(baseIteratee));
|
||||||
|
|
||||||
var funcsLength = transforms.length;
|
var funcsLength = transforms.length;
|
||||||
return rest(function(args) {
|
return rest(function(args) {
|
||||||
var index = -1,
|
var index = -1,
|
||||||
|
|||||||
@@ -9,7 +9,8 @@ import createOver from './_createOver';
|
|||||||
* @memberOf _
|
* @memberOf _
|
||||||
* @since 4.0.0
|
* @since 4.0.0
|
||||||
* @category Util
|
* @category Util
|
||||||
* @param {...(Function|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.
|
* @returns {Function} Returns the new function.
|
||||||
* @example
|
* @example
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -9,7 +9,8 @@ import createOver from './_createOver';
|
|||||||
* @memberOf _
|
* @memberOf _
|
||||||
* @since 4.0.0
|
* @since 4.0.0
|
||||||
* @category Util
|
* @category Util
|
||||||
* @param {...(Function|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.
|
* @returns {Function} Returns the new function.
|
||||||
* @example
|
* @example
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "lodash-es",
|
"name": "lodash-es",
|
||||||
"version": "4.9.0",
|
"version": "4.11.1",
|
||||||
"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",
|
||||||
|
|||||||
3
pick.js
3
pick.js
@@ -10,8 +10,7 @@ import rest from './rest';
|
|||||||
* @memberOf _
|
* @memberOf _
|
||||||
* @category Object
|
* @category Object
|
||||||
* @param {Object} object The source object.
|
* @param {Object} object The source object.
|
||||||
* @param {...(string|string[])} [props] The property identifiers to pick,
|
* @param {...(string|string[])} [props] The property identifiers to pick.
|
||||||
* specified individually or in arrays.
|
|
||||||
* @returns {Object} Returns the new object.
|
* @returns {Object} Returns the new object.
|
||||||
* @example
|
* @example
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -16,8 +16,7 @@ import rest from './rest';
|
|||||||
* @since 3.0.0
|
* @since 3.0.0
|
||||||
* @category Array
|
* @category Array
|
||||||
* @param {Array} array The array to modify.
|
* @param {Array} array The array to modify.
|
||||||
* @param {...(number|number[])} [indexes] The indexes of elements to remove,
|
* @param {...(number|number[])} [indexes] The indexes of elements to remove.
|
||||||
* specified individually or in arrays.
|
|
||||||
* @returns {Array} Returns the new array of removed elements.
|
* @returns {Array} Returns the new array of removed elements.
|
||||||
* @example
|
* @example
|
||||||
*
|
*
|
||||||
|
|||||||
3
rearg.js
3
rearg.js
@@ -16,8 +16,7 @@ var REARG_FLAG = 256;
|
|||||||
* @since 3.0.0
|
* @since 3.0.0
|
||||||
* @category Function
|
* @category Function
|
||||||
* @param {Function} func The function to rearrange arguments for.
|
* @param {Function} func The function to rearrange arguments for.
|
||||||
* @param {...(number|number[])} indexes The arranged argument indexes,
|
* @param {...(number|number[])} indexes The arranged argument indexes.
|
||||||
* specified individually or in arrays.
|
|
||||||
* @returns {Function} Returns the new function.
|
* @returns {Function} Returns the new function.
|
||||||
* @example
|
* @example
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -1,5 +1,11 @@
|
|||||||
import toString from './toString';
|
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`.
|
* Replaces matches for `pattern` in `string` with `replacement`.
|
||||||
*
|
*
|
||||||
@@ -23,7 +29,7 @@ function replace() {
|
|||||||
var args = arguments,
|
var args = arguments,
|
||||||
string = toString(args[0]);
|
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;
|
export default replace;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import baseCastPath from './_baseCastPath';
|
import castPath from './_castPath';
|
||||||
import isFunction from './isFunction';
|
import isFunction from './isFunction';
|
||||||
import isKey from './_isKey';
|
import isKey from './_isKey';
|
||||||
|
|
||||||
@@ -32,7 +32,7 @@ import isKey from './_isKey';
|
|||||||
* // => 'default'
|
* // => 'default'
|
||||||
*/
|
*/
|
||||||
function result(object, path, defaultValue) {
|
function result(object, path, defaultValue) {
|
||||||
path = isKey(path, object) ? [path] : baseCastPath(path);
|
path = isKey(path, object) ? [path] : castPath(path);
|
||||||
|
|
||||||
var index = -1,
|
var index = -1,
|
||||||
length = path.length;
|
length = path.length;
|
||||||
|
|||||||
13
sortBy.js
13
sortBy.js
@@ -1,5 +1,7 @@
|
|||||||
import baseFlatten from './_baseFlatten';
|
import baseFlatten from './_baseFlatten';
|
||||||
import baseOrderBy from './_baseOrderBy';
|
import baseOrderBy from './_baseOrderBy';
|
||||||
|
import isArray from './isArray';
|
||||||
|
import isFlattenableIteratee from './_isFlattenableIteratee';
|
||||||
import isIterateeCall from './_isIterateeCall';
|
import isIterateeCall from './_isIterateeCall';
|
||||||
import rest from './rest';
|
import rest from './rest';
|
||||||
|
|
||||||
@@ -15,8 +17,7 @@ import rest from './rest';
|
|||||||
* @category Collection
|
* @category Collection
|
||||||
* @param {Array|Object} collection The collection to iterate over.
|
* @param {Array|Object} collection The collection to iterate over.
|
||||||
* @param {...(Array|Array[]|Function|Function[]|Object|Object[]|string|string[])}
|
* @param {...(Array|Array[]|Function|Function[]|Object|Object[]|string|string[])}
|
||||||
* [iteratees=[_.identity]] The iteratees to sort by, specified individually
|
* [iteratees=[_.identity]] The iteratees to sort by.
|
||||||
* or in arrays.
|
|
||||||
* @returns {Array} Returns the new sorted array.
|
* @returns {Array} Returns the new sorted array.
|
||||||
* @example
|
* @example
|
||||||
*
|
*
|
||||||
@@ -46,9 +47,13 @@ var sortBy = rest(function(collection, iteratees) {
|
|||||||
if (length > 1 && isIterateeCall(collection, iteratees[0], iteratees[1])) {
|
if (length > 1 && isIterateeCall(collection, iteratees[0], iteratees[1])) {
|
||||||
iteratees = [];
|
iteratees = [];
|
||||||
} else if (length > 2 && isIterateeCall(iteratees[0], iteratees[1], iteratees[2])) {
|
} 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;
|
export default sortBy;
|
||||||
|
|||||||
30
split.js
30
split.js
@@ -1,18 +1,18 @@
|
|||||||
|
import castSlice from './_castSlice';
|
||||||
|
import isIterateeCall from './_isIterateeCall';
|
||||||
import isRegExp from './isRegExp';
|
import isRegExp from './isRegExp';
|
||||||
|
import reHasComplexSymbol from './_reHasComplexSymbol';
|
||||||
import stringToArray from './_stringToArray';
|
import stringToArray from './_stringToArray';
|
||||||
import toString from './toString';
|
import toString from './toString';
|
||||||
|
|
||||||
/** Used to compose unicode character classes. */
|
/** Used as references for the maximum length and index of an array. */
|
||||||
var rsAstralRange = '\\ud800-\\udfff',
|
var MAX_ARRAY_LENGTH = 4294967295;
|
||||||
rsComboMarksRange = '\\u0300-\\u036f\\ufe20-\\ufe23',
|
|
||||||
rsComboSymbolsRange = '\\u20d0-\\u20f0',
|
|
||||||
rsVarRange = '\\ufe0e\\ufe0f';
|
|
||||||
|
|
||||||
/** Used to compose unicode capture groups. */
|
/** Used for built-in method references. */
|
||||||
var rsZWJ = '\\u200d';
|
var stringProto = String.prototype;
|
||||||
|
|
||||||
/** 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/). */
|
/* Built-in method references for those with the same name as other `lodash` methods. */
|
||||||
var reHasComplexSymbol = RegExp('[' + rsZWJ + rsAstralRange + rsComboMarksRange + rsComboSymbolsRange + rsVarRange + ']');
|
var nativeSplit = stringProto.split;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Splits `string` by `separator`.
|
* Splits `string` by `separator`.
|
||||||
@@ -34,6 +34,13 @@ var reHasComplexSymbol = RegExp('[' + rsZWJ + rsAstralRange + rsComboMarksRange
|
|||||||
* // => ['a', 'b']
|
* // => ['a', 'b']
|
||||||
*/
|
*/
|
||||||
function split(string, separator, limit) {
|
function split(string, 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);
|
string = toString(string);
|
||||||
if (string && (
|
if (string && (
|
||||||
typeof separator == 'string' ||
|
typeof separator == 'string' ||
|
||||||
@@ -41,11 +48,10 @@ function split(string, separator, limit) {
|
|||||||
)) {
|
)) {
|
||||||
separator += '';
|
separator += '';
|
||||||
if (separator == '' && reHasComplexSymbol.test(string)) {
|
if (separator == '' && reHasComplexSymbol.test(string)) {
|
||||||
var strSymbols = stringToArray(string);
|
return castSlice(stringToArray(string), 0, limit);
|
||||||
return limit === undefined ? strSymbols : strSymbols.slice(0, limit < 0 ? 0 : limit);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return string.split(separator, limit);
|
return nativeSplit.call(string, separator, limit);
|
||||||
}
|
}
|
||||||
|
|
||||||
export default split;
|
export default split;
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import apply from './_apply';
|
import apply from './_apply';
|
||||||
import arrayPush from './_arrayPush';
|
import arrayPush from './_arrayPush';
|
||||||
|
import castSlice from './_castSlice';
|
||||||
import rest from './rest';
|
import rest from './rest';
|
||||||
import toInteger from './toInteger';
|
import toInteger from './toInteger';
|
||||||
|
|
||||||
@@ -50,7 +51,7 @@ function spread(func, start) {
|
|||||||
start = start === undefined ? 0 : nativeMax(toInteger(start), 0);
|
start = start === undefined ? 0 : nativeMax(toInteger(start), 0);
|
||||||
return rest(function(args) {
|
return rest(function(args) {
|
||||||
var array = args[start],
|
var array = args[start],
|
||||||
otherArgs = args.slice(0, start);
|
otherArgs = castSlice(args, 0, start);
|
||||||
|
|
||||||
if (array) {
|
if (array) {
|
||||||
arrayPush(otherArgs, array);
|
arrayPush(otherArgs, array);
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
import arrayMap from './_arrayMap';
|
import arrayMap from './_arrayMap';
|
||||||
import baseCastKey from './_baseCastKey';
|
|
||||||
import copyArray from './_copyArray';
|
import copyArray from './_copyArray';
|
||||||
import isArray from './isArray';
|
import isArray from './isArray';
|
||||||
import isSymbol from './isSymbol';
|
import isSymbol from './isSymbol';
|
||||||
import stringToPath from './_stringToPath';
|
import stringToPath from './_stringToPath';
|
||||||
|
import toKey from './_toKey';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts `value` to a property path array.
|
* Converts `value` to a property path array.
|
||||||
@@ -33,7 +33,7 @@ import stringToPath from './_stringToPath';
|
|||||||
*/
|
*/
|
||||||
function toPath(value) {
|
function toPath(value) {
|
||||||
if (isArray(value)) {
|
if (isArray(value)) {
|
||||||
return arrayMap(value, baseCastKey);
|
return arrayMap(value, toKey);
|
||||||
}
|
}
|
||||||
return isSymbol(value) ? [value] : copyArray(stringToPath(value));
|
return isSymbol(value) ? [value] : copyArray(stringToPath(value));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,8 +9,8 @@ var symbolProto = Symbol ? Symbol.prototype : undefined,
|
|||||||
symbolToString = symbolProto ? 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. An empty string is returned for `null`
|
||||||
* for `null` and `undefined` values. The sign of `-0` is preserved.
|
* and `undefined` values. The sign of `-0` is preserved.
|
||||||
*
|
*
|
||||||
* @static
|
* @static
|
||||||
* @memberOf _
|
* @memberOf _
|
||||||
|
|||||||
12
trim.js
12
trim.js
@@ -1,3 +1,4 @@
|
|||||||
|
import castSlice from './_castSlice';
|
||||||
import charsEndIndex from './_charsEndIndex';
|
import charsEndIndex from './_charsEndIndex';
|
||||||
import charsStartIndex from './_charsStartIndex';
|
import charsStartIndex from './_charsStartIndex';
|
||||||
import stringToArray from './_stringToArray';
|
import stringToArray from './_stringToArray';
|
||||||
@@ -36,16 +37,15 @@ function trim(string, chars, guard) {
|
|||||||
if (guard || chars === undefined) {
|
if (guard || chars === undefined) {
|
||||||
return string.replace(reTrim, '');
|
return string.replace(reTrim, '');
|
||||||
}
|
}
|
||||||
chars = (chars + '');
|
if (!(chars += '')) {
|
||||||
if (!chars) {
|
|
||||||
return string;
|
return string;
|
||||||
}
|
}
|
||||||
var strSymbols = stringToArray(string),
|
var strSymbols = stringToArray(string),
|
||||||
chrSymbols = stringToArray(chars);
|
chrSymbols = stringToArray(chars),
|
||||||
|
start = charsStartIndex(strSymbols, chrSymbols),
|
||||||
|
end = charsEndIndex(strSymbols, chrSymbols) + 1;
|
||||||
|
|
||||||
return strSymbols
|
return castSlice(strSymbols, start, end).join('');
|
||||||
.slice(charsStartIndex(strSymbols, chrSymbols), charsEndIndex(strSymbols, chrSymbols) + 1)
|
|
||||||
.join('');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default trim;
|
export default trim;
|
||||||
|
|||||||
12
trimEnd.js
12
trimEnd.js
@@ -1,3 +1,4 @@
|
|||||||
|
import castSlice from './_castSlice';
|
||||||
import charsEndIndex from './_charsEndIndex';
|
import charsEndIndex from './_charsEndIndex';
|
||||||
import stringToArray from './_stringToArray';
|
import stringToArray from './_stringToArray';
|
||||||
import toString from './toString';
|
import toString from './toString';
|
||||||
@@ -32,14 +33,13 @@ function trimEnd(string, chars, guard) {
|
|||||||
if (guard || chars === undefined) {
|
if (guard || chars === undefined) {
|
||||||
return string.replace(reTrimEnd, '');
|
return string.replace(reTrimEnd, '');
|
||||||
}
|
}
|
||||||
chars = (chars + '');
|
if (!(chars += '')) {
|
||||||
if (!chars) {
|
|
||||||
return string;
|
return string;
|
||||||
}
|
}
|
||||||
var strSymbols = stringToArray(string);
|
var strSymbols = stringToArray(string),
|
||||||
return strSymbols
|
end = charsEndIndex(strSymbols, stringToArray(chars)) + 1;
|
||||||
.slice(0, charsEndIndex(strSymbols, stringToArray(chars)) + 1)
|
|
||||||
.join('');
|
return castSlice(strSymbols, 0, end).join('');
|
||||||
}
|
}
|
||||||
|
|
||||||
export default trimEnd;
|
export default trimEnd;
|
||||||
|
|||||||
12
trimStart.js
12
trimStart.js
@@ -1,3 +1,4 @@
|
|||||||
|
import castSlice from './_castSlice';
|
||||||
import charsStartIndex from './_charsStartIndex';
|
import charsStartIndex from './_charsStartIndex';
|
||||||
import stringToArray from './_stringToArray';
|
import stringToArray from './_stringToArray';
|
||||||
import toString from './toString';
|
import toString from './toString';
|
||||||
@@ -32,14 +33,13 @@ function trimStart(string, chars, guard) {
|
|||||||
if (guard || chars === undefined) {
|
if (guard || chars === undefined) {
|
||||||
return string.replace(reTrimStart, '');
|
return string.replace(reTrimStart, '');
|
||||||
}
|
}
|
||||||
chars = (chars + '');
|
if (!(chars += '')) {
|
||||||
if (!chars) {
|
|
||||||
return string;
|
return string;
|
||||||
}
|
}
|
||||||
var strSymbols = stringToArray(string);
|
var strSymbols = stringToArray(string),
|
||||||
return strSymbols
|
start = charsStartIndex(strSymbols, stringToArray(chars));
|
||||||
.slice(charsStartIndex(strSymbols, stringToArray(chars)))
|
|
||||||
.join('');
|
return castSlice(strSymbols, start).join('');
|
||||||
}
|
}
|
||||||
|
|
||||||
export default trimStart;
|
export default trimStart;
|
||||||
|
|||||||
16
truncate.js
16
truncate.js
@@ -1,5 +1,7 @@
|
|||||||
|
import castSlice from './_castSlice';
|
||||||
import isObject from './isObject';
|
import isObject from './isObject';
|
||||||
import isRegExp from './isRegExp';
|
import isRegExp from './isRegExp';
|
||||||
|
import reHasComplexSymbol from './_reHasComplexSymbol';
|
||||||
import stringSize from './_stringSize';
|
import stringSize from './_stringSize';
|
||||||
import stringToArray from './_stringToArray';
|
import stringToArray from './_stringToArray';
|
||||||
import toInteger from './toInteger';
|
import toInteger from './toInteger';
|
||||||
@@ -12,18 +14,6 @@ var DEFAULT_TRUNC_LENGTH = 30,
|
|||||||
/** Used to match `RegExp` flags from their coerced string values. */
|
/** Used to match `RegExp` flags from their coerced string values. */
|
||||||
var reFlags = /\w*$/;
|
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.
|
* Truncates `string` if it's longer than the given maximum string length.
|
||||||
* The last characters of the truncated string are replaced with the omission
|
* The last characters of the truncated string are replaced with the omission
|
||||||
@@ -85,7 +75,7 @@ function truncate(string, options) {
|
|||||||
return omission;
|
return omission;
|
||||||
}
|
}
|
||||||
var result = strSymbols
|
var result = strSymbols
|
||||||
? strSymbols.slice(0, end).join('')
|
? castSlice(strSymbols, 0, end).join('')
|
||||||
: string.slice(0, end);
|
: string.slice(0, end);
|
||||||
|
|
||||||
if (separator === undefined) {
|
if (separator === undefined) {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import baseCastFunction from './_baseCastFunction';
|
|
||||||
import baseUpdate from './_baseUpdate';
|
import baseUpdate from './_baseUpdate';
|
||||||
|
import castFunction from './_castFunction';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method is like `_.set` except that accepts `updater` to produce the
|
* This method is like `_.set` except that accepts `updater` to produce the
|
||||||
@@ -29,7 +29,7 @@ import baseUpdate from './_baseUpdate';
|
|||||||
* // => 0
|
* // => 0
|
||||||
*/
|
*/
|
||||||
function update(object, path, updater) {
|
function update(object, path, updater) {
|
||||||
return object == null ? object : baseUpdate(object, path, baseCastFunction(updater));
|
return object == null ? object : baseUpdate(object, path, castFunction(updater));
|
||||||
}
|
}
|
||||||
|
|
||||||
export default update;
|
export default update;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import baseCastFunction from './_baseCastFunction';
|
|
||||||
import baseUpdate from './_baseUpdate';
|
import baseUpdate from './_baseUpdate';
|
||||||
|
import castFunction from './_castFunction';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method is like `_.update` except that it accepts `customizer` which is
|
* This method is like `_.update` except that it accepts `customizer` which is
|
||||||
@@ -27,7 +27,7 @@ import baseUpdate from './_baseUpdate';
|
|||||||
*/
|
*/
|
||||||
function updateWith(object, path, updater, customizer) {
|
function updateWith(object, path, updater, customizer) {
|
||||||
customizer = typeof customizer == 'function' ? customizer : undefined;
|
customizer = typeof customizer == 'function' ? customizer : undefined;
|
||||||
return object == null ? object : baseUpdate(object, path, baseCastFunction(updater), customizer);
|
return object == null ? object : baseUpdate(object, path, castFunction(updater), customizer);
|
||||||
}
|
}
|
||||||
|
|
||||||
export default updateWith;
|
export default updateWith;
|
||||||
|
|||||||
19
words.js
19
words.js
@@ -1,5 +1,8 @@
|
|||||||
import toString from './toString';
|
import toString from './toString';
|
||||||
|
|
||||||
|
/** Used to match non-compound words composed of alphanumeric characters. */
|
||||||
|
var reBasicWord = /[a-zA-Z0-9]+/g;
|
||||||
|
|
||||||
/** Used to compose unicode character classes. */
|
/** Used to compose unicode character classes. */
|
||||||
var rsAstralRange = '\\ud800-\\udfff',
|
var rsAstralRange = '\\ud800-\\udfff',
|
||||||
rsComboMarksRange = '\\u0300-\\u036f\\ufe20-\\ufe23',
|
rsComboMarksRange = '\\u0300-\\u036f\\ufe20-\\ufe23',
|
||||||
@@ -15,7 +18,8 @@ var rsAstralRange = '\\ud800-\\udfff',
|
|||||||
rsBreakRange = rsMathOpRange + rsNonCharRange + rsQuoteRange + rsSpaceRange;
|
rsBreakRange = rsMathOpRange + rsNonCharRange + rsQuoteRange + rsSpaceRange;
|
||||||
|
|
||||||
/** Used to compose unicode capture groups. */
|
/** Used to compose unicode capture groups. */
|
||||||
var rsBreak = '[' + rsBreakRange + ']',
|
var rsApos = "['\u2019]",
|
||||||
|
rsBreak = '[' + rsBreakRange + ']',
|
||||||
rsCombo = '[' + rsComboMarksRange + rsComboSymbolsRange + ']',
|
rsCombo = '[' + rsComboMarksRange + rsComboSymbolsRange + ']',
|
||||||
rsDigits = '\\d+',
|
rsDigits = '\\d+',
|
||||||
rsDingbat = '[' + rsDingbatRange + ']',
|
rsDingbat = '[' + rsDingbatRange + ']',
|
||||||
@@ -32,21 +36,20 @@ var rsBreak = '[' + rsBreakRange + ']',
|
|||||||
/** Used to compose unicode regexes. */
|
/** Used to compose unicode regexes. */
|
||||||
var rsLowerMisc = '(?:' + rsLower + '|' + rsMisc + ')',
|
var rsLowerMisc = '(?:' + rsLower + '|' + rsMisc + ')',
|
||||||
rsUpperMisc = '(?:' + rsUpper + '|' + rsMisc + ')',
|
rsUpperMisc = '(?:' + rsUpper + '|' + rsMisc + ')',
|
||||||
|
rsOptLowerContr = '(?:' + rsApos + '(?:d|ll|m|re|s|t|ve))?',
|
||||||
|
rsOptUpperContr = '(?:' + rsApos + '(?:D|LL|M|RE|S|T|VE))?',
|
||||||
reOptMod = rsModifier + '?',
|
reOptMod = rsModifier + '?',
|
||||||
rsOptVar = '[' + rsVarRange + ']?',
|
rsOptVar = '[' + rsVarRange + ']?',
|
||||||
rsOptJoin = '(?:' + rsZWJ + '(?:' + [rsNonAstral, rsRegional, rsSurrPair].join('|') + ')' + rsOptVar + reOptMod + ')*',
|
rsOptJoin = '(?:' + rsZWJ + '(?:' + [rsNonAstral, rsRegional, rsSurrPair].join('|') + ')' + rsOptVar + reOptMod + ')*',
|
||||||
rsSeq = rsOptVar + reOptMod + rsOptJoin,
|
rsSeq = rsOptVar + reOptMod + rsOptJoin,
|
||||||
rsEmoji = '(?:' + [rsDingbat, rsRegional, rsSurrPair].join('|') + ')' + rsSeq;
|
rsEmoji = '(?:' + [rsDingbat, rsRegional, rsSurrPair].join('|') + ')' + rsSeq;
|
||||||
|
|
||||||
/** Used to match non-compound words composed of alphanumeric characters. */
|
|
||||||
var reBasicWord = /[a-zA-Z0-9]+/g;
|
|
||||||
|
|
||||||
/** Used to match complex or compound words. */
|
/** Used to match complex or compound words. */
|
||||||
var reComplexWord = RegExp([
|
var reComplexWord = RegExp([
|
||||||
rsUpper + '?' + rsLower + '+(?=' + [rsBreak, rsUpper, '$'].join('|') + ')',
|
rsUpper + '?' + rsLower + '+' + rsOptLowerContr + '(?=' + [rsBreak, rsUpper, '$'].join('|') + ')',
|
||||||
rsUpperMisc + '+(?=' + [rsBreak, rsUpper + rsLowerMisc, '$'].join('|') + ')',
|
rsUpperMisc + '+' + rsOptUpperContr + '(?=' + [rsBreak, rsUpper + rsLowerMisc, '$'].join('|') + ')',
|
||||||
rsUpper + '?' + rsLowerMisc + '+',
|
rsUpper + '?' + rsLowerMisc + '+' + rsOptLowerContr,
|
||||||
rsUpper + '+',
|
rsUpper + '+' + rsOptUpperContr,
|
||||||
rsDigits,
|
rsDigits,
|
||||||
rsEmoji
|
rsEmoji
|
||||||
].join('|'), 'g');
|
].join('|'), 'g');
|
||||||
|
|||||||
@@ -13,8 +13,7 @@ import thru from './thru';
|
|||||||
* @memberOf _
|
* @memberOf _
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
* @category Seq
|
* @category Seq
|
||||||
* @param {...(string|string[])} [paths] The property paths of elements to pick,
|
* @param {...(string|string[])} [paths] The property paths of elements to pick.
|
||||||
* specified individually or in arrays.
|
|
||||||
* @returns {Object} Returns the new `lodash` wrapper instance.
|
* @returns {Object} Returns the new `lodash` wrapper instance.
|
||||||
* @example
|
* @example
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ var hasOwnProperty = objectProto.hasOwnProperty;
|
|||||||
* `isSet`, `isString`, `isUndefined`, `isTypedArray`, `isWeakMap`, `isWeakSet`,
|
* `isSet`, `isString`, `isUndefined`, `isTypedArray`, `isWeakMap`, `isWeakSet`,
|
||||||
* `join`, `kebabCase`, `last`, `lastIndexOf`, `lowerCase`, `lowerFirst`,
|
* `join`, `kebabCase`, `last`, `lastIndexOf`, `lowerCase`, `lowerFirst`,
|
||||||
* `lt`, `lte`, `max`, `maxBy`, `mean`, `meanBy`, `min`, `minBy`, `multiply`,
|
* `lt`, `lte`, `max`, `maxBy`, `mean`, `meanBy`, `min`, `minBy`, `multiply`,
|
||||||
* `noConflict`, `noop`, `now`, `pad`, `padEnd`, `padStart`, `parseInt`,
|
* `noConflict`, `noop`, `now`, `nth`, `pad`, `padEnd`, `padStart`, `parseInt`,
|
||||||
* `pop`, `random`, `reduce`, `reduceRight`, `repeat`, `result`, `round`,
|
* `pop`, `random`, `reduce`, `reduceRight`, `repeat`, `result`, `round`,
|
||||||
* `runInContext`, `sample`, `shift`, `size`, `snakeCase`, `some`, `sortedIndex`,
|
* `runInContext`, `sample`, `shift`, `size`, `snakeCase`, `some`, `sortedIndex`,
|
||||||
* `sortedIndexBy`, `sortedLastIndex`, `sortedLastIndexBy`, `startCase`,
|
* `sortedIndexBy`, `sortedLastIndex`, `sortedLastIndexBy`, `startCase`,
|
||||||
|
|||||||
Reference in New Issue
Block a user