source: node_modules/ramda/es/unary.js

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: 1.0 KB
RevLine 
[d24f17c]1import _curry1 from "./internal/_curry1.js";
2import nAry from "./nAry.js";
3/**
4 * Wraps a function of any arity (including nullary) in a function that accepts
5 * exactly 1 parameter. Any extraneous parameters will not be passed to the
6 * supplied function.
7 *
8 * @func
9 * @memberOf R
10 * @since v0.2.0
11 * @category Function
12 * @sig (a -> b -> c -> ... -> z) -> (a -> z)
13 * @param {Function} fn The function to wrap.
14 * @return {Function} A new function wrapping `fn`. The new function is guaranteed to be of
15 * arity 1.
16 * @see R.binary, R.nAry
17 * @example
18 *
19 * const takesTwoArgs = function(a, b) {
20 * return [a, b];
21 * };
22 * takesTwoArgs.length; //=> 2
23 * takesTwoArgs(1, 2); //=> [1, 2]
24 *
25 * const takesOneArg = R.unary(takesTwoArgs);
26 * takesOneArg.length; //=> 1
27 * // Only 1 argument is passed to the wrapped function
28 * takesOneArg(1, 2); //=> [1, undefined]
29 * @symb R.unary(f)(a, b, c) = f(a)
30 */
31
32var unary =
33/*#__PURE__*/
34_curry1(function unary(fn) {
35 return nAry(1, fn);
36});
37
38export default unary;
Note: See TracBrowser for help on using the repository browser.