Projekt

Obecné

Profil

Stáhnout (1023 Bajtů) Statistiky
| Větev: | Revize:
1 3a515b92 cagy
var createWrap = require('./_createWrap'),
2
    flatRest = require('./_flatRest');
3
4
/** Used to compose bitmasks for function metadata. */
5
var WRAP_REARG_FLAG = 256;
6
7
/**
8
 * Creates a function that invokes `func` with arguments arranged according
9
 * to the specified `indexes` where the argument value at the first index is
10
 * provided as the first argument, the argument value at the second index is
11
 * provided as the second argument, and so on.
12
 *
13
 * @static
14
 * @memberOf _
15
 * @since 3.0.0
16
 * @category Function
17
 * @param {Function} func The function to rearrange arguments for.
18
 * @param {...(number|number[])} indexes The arranged argument indexes.
19
 * @returns {Function} Returns the new function.
20
 * @example
21
 *
22
 * var rearged = _.rearg(function(a, b, c) {
23
 *   return [a, b, c];
24
 * }, [2, 0, 1]);
25
 *
26
 * rearged('b', 'c', 'a')
27
 * // => ['a', 'b', 'c']
28
 */
29
var rearg = flatRest(function(func, indexes) {
30
  return createWrap(func, WRAP_REARG_FLAG, undefined, undefined, undefined, indexes);
31
});
32
33
module.exports = rearg;