source: trip-planner-front/node_modules/lodash/nthArg.js@ 6c1585f

Last change on this file since 6c1585f was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 730 bytes
Line 
1var baseNth = require('./_baseNth'),
2 baseRest = require('./_baseRest'),
3 toInteger = require('./toInteger');
4
5/**
6 * Creates a function that gets the argument at index `n`. If `n` is negative,
7 * the nth argument from the end is returned.
8 *
9 * @static
10 * @memberOf _
11 * @since 4.0.0
12 * @category Util
13 * @param {number} [n=0] The index of the argument to return.
14 * @returns {Function} Returns the new pass-thru function.
15 * @example
16 *
17 * var func = _.nthArg(1);
18 * func('a', 'b', 'c', 'd');
19 * // => 'b'
20 *
21 * var func = _.nthArg(-2);
22 * func('a', 'b', 'c', 'd');
23 * // => 'c'
24 */
25function nthArg(n) {
26 n = toInteger(n);
27 return baseRest(function(args) {
28 return baseNth(args, n);
29 });
30}
31
32module.exports = nthArg;
Note: See TracBrowser for help on using the repository browser.