mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-03 16:47:49 +00:00
Add _.nthArg.
This commit is contained in:
33
lodash.js
33
lodash.js
@@ -1424,11 +1424,11 @@
|
||||
* `functions`, `groupBy`, `initial`, `intersection`, `intersectionBy`,
|
||||
* `invert`, `invoke`, `iteratee`, `keyBy`, `keys`, `keysIn`, `map`, `mapKeys`,
|
||||
* `mapValues`, `matches`, `matchesProperty`, `memoize`, `merge`, `mergeWith`,
|
||||
* `method`, `methodOf`, `mixin`, `modArgs`, `modArgsSet', 'negate`, `omit`,
|
||||
* `omitBy`, `once`, `pairs`, `partial`, `partialRight`, `partition`, `pick`,
|
||||
* `pickBy`, `plant`, `property`, `propertyOf`, `pull`, `pullAll`, `pullAllBy`,
|
||||
* `pullAt`, `push`, `range`, `rearg`, `reject`, `remove`, `rest`, `reverse`,
|
||||
* `sampleSize`, `set`, `setWith`, `shuffle`, `slice`, `sort`, `sortBy`,
|
||||
* `method`, `methodOf`, `mixin`, `modArgs`, `modArgsSet', 'negate`, `nthArg`,
|
||||
* `omit`, `omitBy`, `once`, `pairs`, `partial`, `partialRight`, `partition`,
|
||||
* `pick`, `pickBy`, `plant`, `property`, `propertyOf`, `pull`, `pullAll`,
|
||||
* `pullAllBy`, `pullAt`, `push`, `range`, `rearg`, `reject`, `remove`, `rest`,
|
||||
* `reverse`, `sampleSize`, `set`, `setWith`, `shuffle`, `slice`, `sort`, `sortBy`,
|
||||
* `sortByOrder`, `splice`, `spread`, `tail`, `take`, `takeRight`, `takeRightWhile`,
|
||||
* `takeWhile`, `tap`, `throttle`, `thru`, `times`, `toArray`, `toPath`,
|
||||
* `toPlainObject`, `transform`, `union`, `unionBy`, `uniq`, `uniqBy`, `unset`,
|
||||
@@ -12505,6 +12505,28 @@
|
||||
// No operation performed.
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a function that returns its nth argument.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @category Utility
|
||||
* @param {number} [n=0] The index of the argument to return.
|
||||
* @returns {Function} Returns the new function.
|
||||
* @example
|
||||
*
|
||||
* var func = _.nthArg(1);
|
||||
*
|
||||
* func('a', 'b', 'c');
|
||||
* // => 'b'
|
||||
*/
|
||||
function nthArg(n) {
|
||||
n = toInteger(n);
|
||||
return function() {
|
||||
return arguments[n];
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a function that returns the value at `path` of a given object.
|
||||
*
|
||||
@@ -13050,6 +13072,7 @@
|
||||
lodash.modArgs = modArgs;
|
||||
lodash.modArgsSet = modArgsSet;
|
||||
lodash.negate = negate;
|
||||
lodash.nthArg = nthArg;
|
||||
lodash.omit = omit;
|
||||
lodash.omitBy = omitBy;
|
||||
lodash.once = once;
|
||||
|
||||
@@ -21768,7 +21768,7 @@
|
||||
var acceptFalsey = lodashStable.difference(allMethods, rejectFalsey);
|
||||
|
||||
QUnit.test('should accept falsey arguments', function(assert) {
|
||||
assert.expect(262);
|
||||
assert.expect(263);
|
||||
|
||||
var emptyArrays = lodashStable.map(falsey, lodashStable.constant([]));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user