source: trip-planner-front/node_modules/lodash/rest.js@ 6fe77af

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

initial commit

  • Property mode set to 100644
File size: 1.2 KB
Line 
1var baseRest = require('./_baseRest'),
2 toInteger = require('./toInteger');
3
4/** Error message constants. */
5var FUNC_ERROR_TEXT = 'Expected a function';
6
7/**
8 * Creates a function that invokes `func` with the `this` binding of the
9 * created function and arguments from `start` and beyond provided as
10 * an array.
11 *
12 * **Note:** This method is based on the
13 * [rest parameter](https://mdn.io/rest_parameters).
14 *
15 * @static
16 * @memberOf _
17 * @since 4.0.0
18 * @category Function
19 * @param {Function} func The function to apply a rest parameter to.
20 * @param {number} [start=func.length-1] The start position of the rest parameter.
21 * @returns {Function} Returns the new function.
22 * @example
23 *
24 * var say = _.rest(function(what, names) {
25 * return what + ' ' + _.initial(names).join(', ') +
26 * (_.size(names) > 1 ? ', & ' : '') + _.last(names);
27 * });
28 *
29 * say('hello', 'fred', 'barney', 'pebbles');
30 * // => 'hello fred, barney, & pebbles'
31 */
32function rest(func, start) {
33 if (typeof func != 'function') {
34 throw new TypeError(FUNC_ERROR_TEXT);
35 }
36 start = start === undefined ? start : toInteger(start);
37 return baseRest(func, start);
38}
39
40module.exports = rest;
Note: See TracBrowser for help on using the repository browser.