source: node_modules/ramda/es/call.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.2 KB
RevLine 
[d24f17c]1import _curry1 from "./internal/_curry1.js";
2/**
3 * Returns the result of calling its first argument with the remaining
4 * arguments. This is occasionally useful as a converging function for
5 * [`R.converge`](#converge): the first branch can produce a function while the
6 * remaining branches produce values to be passed to that function as its
7 * arguments.
8 *
9 * @func
10 * @memberOf R
11 * @since v0.9.0
12 * @category Function
13 * @sig ((*... -> a), *...) -> a
14 * @param {Function} fn The function to apply to the remaining arguments.
15 * @param {...*} args Any number of positional arguments.
16 * @return {*}
17 * @see R.apply
18 * @example
19 *
20 * R.call(R.add, 1, 2); //=> 3
21 *
22 * const indentN = R.pipe(
23 * R.repeat(' '),
24 * R.join(''),
25 * R.replace(/^(?!$)/gm)
26 * );
27 *
28 * const format = R.converge(
29 * R.call,
30 * [
31 * R.pipe(R.prop('indent'), indentN),
32 * R.prop('value')
33 * ]
34 * );
35 *
36 * format({indent: 2, value: 'foo\nbar\nbaz\n'}); //=> ' foo\n bar\n baz\n'
37 * @symb R.call(f, a, b) = f(a, b)
38 */
39
40var call =
41/*#__PURE__*/
42_curry1(function call(fn) {
43 return fn.apply(this, Array.prototype.slice.call(arguments, 1));
44});
45
46export default call;
Note: See TracBrowser for help on using the repository browser.