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.1 KB
|
Line | |
---|
1 | import _curry1 from "./internal/_curry1.js";
|
---|
2 | import nAry from "./nAry.js";
|
---|
3 | /**
|
---|
4 | * Wraps a function of any arity (including nullary) in a function that accepts
|
---|
5 | * exactly 2 parameters. 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, b) -> 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 2.
|
---|
16 | * @see R.nAry, R.unary
|
---|
17 | * @example
|
---|
18 | *
|
---|
19 | * const takesThreeArgs = function(a, b, c) {
|
---|
20 | * return [a, b, c];
|
---|
21 | * };
|
---|
22 | * takesThreeArgs.length; //=> 3
|
---|
23 | * takesThreeArgs(1, 2, 3); //=> [1, 2, 3]
|
---|
24 | *
|
---|
25 | * const takesTwoArgs = R.binary(takesThreeArgs);
|
---|
26 | * takesTwoArgs.length; //=> 2
|
---|
27 | * // Only 2 arguments are passed to the wrapped function
|
---|
28 | * takesTwoArgs(1, 2, 3); //=> [1, 2, undefined]
|
---|
29 | * @symb R.binary(f)(a, b, c) = f(a, b)
|
---|
30 | */
|
---|
31 |
|
---|
32 | var binary =
|
---|
33 | /*#__PURE__*/
|
---|
34 | _curry1(function binary(fn) {
|
---|
35 | return nAry(2, fn);
|
---|
36 | });
|
---|
37 |
|
---|
38 | export default binary; |
---|
Note:
See
TracBrowser
for help on using the repository browser.