UNPKG

1.08 kBJavaScriptView Raw
1var _curry1 =
2/*#__PURE__*/
3require("./internal/_curry1");
4
5var nAry =
6/*#__PURE__*/
7require("./nAry");
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 (* -> b) -> (a -> b)
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
38var unary =
39/*#__PURE__*/
40_curry1(function unary(fn) {
41 return nAry(1, fn);
42});
43
44module.exports = unary;
\No newline at end of file