You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

31 lines
705 B

4 years ago
  1. import _curry1 from "./internal/_curry1.js";
  2. import curryN from "./curryN.js";
  3. import nth from "./nth.js";
  4. /**
  5. * Returns a function which returns its nth argument.
  6. *
  7. * @func
  8. * @memberOf R
  9. * @since v0.9.0
  10. * @category Function
  11. * @sig Number -> *... -> *
  12. * @param {Number} n
  13. * @return {Function}
  14. * @example
  15. *
  16. * R.nthArg(1)('a', 'b', 'c'); //=> 'b'
  17. * R.nthArg(-1)('a', 'b', 'c'); //=> 'c'
  18. * @symb R.nthArg(-1)(a, b, c) = c
  19. * @symb R.nthArg(0)(a, b, c) = a
  20. * @symb R.nthArg(1)(a, b, c) = b
  21. */
  22. var nthArg =
  23. /*#__PURE__*/
  24. _curry1(function nthArg(n) {
  25. var arity = n < 0 ? 1 : n + 1;
  26. return curryN(arity, function () {
  27. return nth(n, arguments);
  28. });
  29. });
  30. export default nthArg;