main
Last change
on this file was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 15 months ago |
Initial commit
|
-
Property mode
set to
100644
|
File size:
705 bytes
|
Rev | Line | |
---|
[d24f17c] | 1 | import _curry1 from "./internal/_curry1.js";
|
---|
| 2 | import curryN from "./curryN.js";
|
---|
| 3 | import nth from "./nth.js";
|
---|
| 4 | /**
|
---|
| 5 | * Returns a function which returns its nth argument.
|
---|
| 6 | *
|
---|
| 7 | * @func
|
---|
| 8 | * @memberOf R
|
---|
| 9 | * @since v0.9.0
|
---|
| 10 | * @category Function
|
---|
| 11 | * @sig Number -> *... -> *
|
---|
| 12 | * @param {Number} n
|
---|
| 13 | * @return {Function}
|
---|
| 14 | * @example
|
---|
| 15 | *
|
---|
| 16 | * R.nthArg(1)('a', 'b', 'c'); //=> 'b'
|
---|
| 17 | * R.nthArg(-1)('a', 'b', 'c'); //=> 'c'
|
---|
| 18 | * @symb R.nthArg(-1)(a, b, c) = c
|
---|
| 19 | * @symb R.nthArg(0)(a, b, c) = a
|
---|
| 20 | * @symb R.nthArg(1)(a, b, c) = b
|
---|
| 21 | */
|
---|
| 22 |
|
---|
| 23 | var nthArg =
|
---|
| 24 | /*#__PURE__*/
|
---|
| 25 | _curry1(function nthArg(n) {
|
---|
| 26 | var arity = n < 0 ? 1 : n + 1;
|
---|
| 27 | return curryN(arity, function () {
|
---|
| 28 | return nth(n, arguments);
|
---|
| 29 | });
|
---|
| 30 | });
|
---|
| 31 |
|
---|
| 32 | export default nthArg; |
---|
Note:
See
TracBrowser
for help on using the repository browser.