mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-06 17:47:49 +00:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
764eccfdc0 |
@@ -1,4 +1,4 @@
|
|||||||
# lodash-es v4.10.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.
|
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.10.0-es) for more details.
|
See the [package source](https://github.com/lodash/lodash/tree/4.11.0-es) for more details.
|
||||||
|
|||||||
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 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;
|
|
||||||
@@ -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,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,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) {
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
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 @@
|
|||||||
/**
|
/**
|
||||||
* @license
|
* @license
|
||||||
* lodash 4.10.0 (Custom Build) <https://lodash.com/>
|
* lodash 4.11.0 (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.10.0';
|
var VERSION = '4.11.0';
|
||||||
|
|
||||||
/** Used to compose bitmasks for wrapper metadata. */
|
/** Used to compose bitmasks for wrapper metadata. */
|
||||||
var BIND_KEY_FLAG = 2;
|
var BIND_KEY_FLAG = 2;
|
||||||
@@ -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.10.0 (Custom Build) <https://lodash.com/>
|
* lodash 4.11.0 (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';
|
||||||
|
|||||||
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;
|
||||||
|
|||||||
@@ -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';
|
||||||
|
|
||||||
@@ -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,
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "lodash-es",
|
"name": "lodash-es",
|
||||||
"version": "4.10.0",
|
"version": "4.11.0",
|
||||||
"description": "Lodash exported as ES modules.",
|
"description": "Lodash exported as ES modules.",
|
||||||
"homepage": "https://lodash.com/custom-builds",
|
"homepage": "https://lodash.com/custom-builds",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
|||||||
@@ -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,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';
|
||||||
|
|
||||||
@@ -47,7 +49,11 @@ var sortBy = rest(function(collection, iteratees) {
|
|||||||
} else if (length > 2 && isIterateeCall(iteratees[0], iteratees[1], iteratees[2])) {
|
} else if (length > 2 && isIterateeCall(iteratees[0], iteratees[1], iteratees[2])) {
|
||||||
iteratees = [iteratees[0]];
|
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;
|
||||||
|
|||||||
8
split.js
8
split.js
@@ -8,6 +8,12 @@ import toString from './toString';
|
|||||||
/** Used as references for the maximum length and index of an array. */
|
/** Used as references for the maximum length and index of an array. */
|
||||||
var MAX_ARRAY_LENGTH = 4294967295;
|
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`.
|
* Splits `string` by `separator`.
|
||||||
*
|
*
|
||||||
@@ -45,7 +51,7 @@ function split(string, separator, limit) {
|
|||||||
return castSlice(stringToArray(string), 0, limit);
|
return castSlice(stringToArray(string), 0, limit);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return string.split(separator, limit);
|
return nativeSplit.call(string, separator, limit);
|
||||||
}
|
}
|
||||||
|
|
||||||
export default split;
|
export default split;
|
||||||
|
|||||||
13
words.js
13
words.js
@@ -18,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 + ']',
|
||||||
@@ -35,6 +36,8 @@ 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 + ')*',
|
||||||
@@ -43,10 +46,10 @@ var rsLowerMisc = '(?:' + rsLower + '|' + rsMisc + ')',
|
|||||||
|
|
||||||
/** 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');
|
||||||
|
|||||||
@@ -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