source: node_modules/ramda-adjunct/es/curryRightN.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.1 KB
Line 
1import { curryN, reverse } from 'ramda';
2
3/**
4 * Returns a curried equivalent of the provided function, with the specified arity.
5 * This function is like curryN, except that the provided arguments order is reversed.
6 *
7 * @func curryRightN
8 * @memberOf RA
9 * @since {@link https://char0n.github.io/ramda-adjunct/1.12.0|v1.12.0}
10 * @category Function
11 * @sig Number -> (* -> a) -> (* -> a)
12 * @param {number} length The arity for the returned function
13 * @param {Function} fn The function to curry
14 * @return {Function} A new, curried function
15 * @see {@link http://ramdajs.com/docs/#curryN|R.curryN}, {@link RA.curryRight|curryRight}
16 * @example
17 *
18 * const concatStrings = (a, b, c) => a + b + c;
19 * const concatStringsCurried = RA.curryRightN(3, concatStrings);
20 *
21 * concatStringCurried('a')('b')('c'); // => 'cba'
22 */
23var curryRightN = curryN(2, function (arity, fn) {
24 return curryN(arity, function wrapper() {
25 for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
26 args[_key] = arguments[_key];
27 }
28 return fn.apply(this, reverse(args));
29 });
30});
31export default curryRightN;
Note: See TracBrowser for help on using the repository browser.