main
Last change
on this file since 65b6638 was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 15 months ago |
Initial commit
|
-
Property mode
set to
100644
|
File size:
1.1 KB
|
Rev | Line | |
---|
[d24f17c] | 1 | var _curry1 =
|
---|
| 2 | /*#__PURE__*/
|
---|
| 3 | require("./internal/_curry1.js");
|
---|
| 4 |
|
---|
| 5 | var nAry =
|
---|
| 6 | /*#__PURE__*/
|
---|
| 7 | require("./nAry.js");
|
---|
| 8 | /**
|
---|
| 9 | * Wraps a function of any arity (including nullary) in a function that accepts
|
---|
| 10 | * exactly 1 parameter. Any extraneous parameters will not be passed to the
|
---|
| 11 | * supplied function.
|
---|
| 12 | *
|
---|
| 13 | * @func
|
---|
| 14 | * @memberOf R
|
---|
| 15 | * @since v0.2.0
|
---|
| 16 | * @category Function
|
---|
| 17 | * @sig (a -> b -> c -> ... -> z) -> (a -> z)
|
---|
| 18 | * @param {Function} fn The function to wrap.
|
---|
| 19 | * @return {Function} A new function wrapping `fn`. The new function is guaranteed to be of
|
---|
| 20 | * arity 1.
|
---|
| 21 | * @see R.binary, R.nAry
|
---|
| 22 | * @example
|
---|
| 23 | *
|
---|
| 24 | * const takesTwoArgs = function(a, b) {
|
---|
| 25 | * return [a, b];
|
---|
| 26 | * };
|
---|
| 27 | * takesTwoArgs.length; //=> 2
|
---|
| 28 | * takesTwoArgs(1, 2); //=> [1, 2]
|
---|
| 29 | *
|
---|
| 30 | * const takesOneArg = R.unary(takesTwoArgs);
|
---|
| 31 | * takesOneArg.length; //=> 1
|
---|
| 32 | * // Only 1 argument is passed to the wrapped function
|
---|
| 33 | * takesOneArg(1, 2); //=> [1, undefined]
|
---|
| 34 | * @symb R.unary(f)(a, b, c) = f(a)
|
---|
| 35 | */
|
---|
| 36 |
|
---|
| 37 |
|
---|
| 38 | var unary =
|
---|
| 39 | /*#__PURE__*/
|
---|
| 40 | _curry1(function unary(fn) {
|
---|
| 41 | return nAry(1, fn);
|
---|
| 42 | });
|
---|
| 43 |
|
---|
| 44 | module.exports = unary; |
---|
Note:
See
TracBrowser
for help on using the repository browser.