main
Last change
on this file was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago |
Update repo after prototype presentation
|
-
Property mode
set to
100644
|
File size:
1021 bytes
|
Rev | Line | |
---|
[d565449] | 1 | import createWrap from './_createWrap.js';
|
---|
| 2 | import flatRest from './_flatRest.js';
|
---|
| 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 | export default rearg;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.