mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-13 04:17: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`,
|
* `functions`, `groupBy`, `initial`, `intersection`, `intersectionBy`,
|
||||||
* `invert`, `invoke`, `iteratee`, `keyBy`, `keys`, `keysIn`, `map`, `mapKeys`,
|
* `invert`, `invoke`, `iteratee`, `keyBy`, `keys`, `keysIn`, `map`, `mapKeys`,
|
||||||
* `mapValues`, `matches`, `matchesProperty`, `memoize`, `merge`, `mergeWith`,
|
* `mapValues`, `matches`, `matchesProperty`, `memoize`, `merge`, `mergeWith`,
|
||||||
* `method`, `methodOf`, `mixin`, `modArgs`, `modArgsSet', 'negate`, `omit`,
|
* `method`, `methodOf`, `mixin`, `modArgs`, `modArgsSet', 'negate`, `nthArg`,
|
||||||
* `omitBy`, `once`, `pairs`, `partial`, `partialRight`, `partition`, `pick`,
|
* `omit`, `omitBy`, `once`, `pairs`, `partial`, `partialRight`, `partition`,
|
||||||
* `pickBy`, `plant`, `property`, `propertyOf`, `pull`, `pullAll`, `pullAllBy`,
|
* `pick`, `pickBy`, `plant`, `property`, `propertyOf`, `pull`, `pullAll`,
|
||||||
* `pullAt`, `push`, `range`, `rearg`, `reject`, `remove`, `rest`, `reverse`,
|
* `pullAllBy`, `pullAt`, `push`, `range`, `rearg`, `reject`, `remove`, `rest`,
|
||||||
* `sampleSize`, `set`, `setWith`, `shuffle`, `slice`, `sort`, `sortBy`,
|
* `reverse`, `sampleSize`, `set`, `setWith`, `shuffle`, `slice`, `sort`, `sortBy`,
|
||||||
* `sortByOrder`, `splice`, `spread`, `tail`, `take`, `takeRight`, `takeRightWhile`,
|
* `sortByOrder`, `splice`, `spread`, `tail`, `take`, `takeRight`, `takeRightWhile`,
|
||||||
* `takeWhile`, `tap`, `throttle`, `thru`, `times`, `toArray`, `toPath`,
|
* `takeWhile`, `tap`, `throttle`, `thru`, `times`, `toArray`, `toPath`,
|
||||||
* `toPlainObject`, `transform`, `union`, `unionBy`, `uniq`, `uniqBy`, `unset`,
|
* `toPlainObject`, `transform`, `union`, `unionBy`, `uniq`, `uniqBy`, `unset`,
|
||||||
@@ -12505,6 +12505,28 @@
|
|||||||
// No operation performed.
|
// 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.
|
* Creates a function that returns the value at `path` of a given object.
|
||||||
*
|
*
|
||||||
@@ -13050,6 +13072,7 @@
|
|||||||
lodash.modArgs = modArgs;
|
lodash.modArgs = modArgs;
|
||||||
lodash.modArgsSet = modArgsSet;
|
lodash.modArgsSet = modArgsSet;
|
||||||
lodash.negate = negate;
|
lodash.negate = negate;
|
||||||
|
lodash.nthArg = nthArg;
|
||||||
lodash.omit = omit;
|
lodash.omit = omit;
|
||||||
lodash.omitBy = omitBy;
|
lodash.omitBy = omitBy;
|
||||||
lodash.once = once;
|
lodash.once = once;
|
||||||
|
|||||||
@@ -21768,7 +21768,7 @@
|
|||||||
var acceptFalsey = lodashStable.difference(allMethods, rejectFalsey);
|
var acceptFalsey = lodashStable.difference(allMethods, rejectFalsey);
|
||||||
|
|
||||||
QUnit.test('should accept falsey arguments', function(assert) {
|
QUnit.test('should accept falsey arguments', function(assert) {
|
||||||
assert.expect(262);
|
assert.expect(263);
|
||||||
|
|
||||||
var emptyArrays = lodashStable.map(falsey, lodashStable.constant([]));
|
var emptyArrays = lodashStable.map(falsey, lodashStable.constant([]));
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user