apply.js 826 B

1234567891011121314151617181920212223242526272829
  1. import _curry2 from "./internal/_curry2.js";
  2. /**
  3. * Applies function `fn` to the argument list `args`. This is useful for
  4. * creating a fixed-arity function from a variadic function. `fn` should be a
  5. * bound function if context is significant.
  6. *
  7. * @func
  8. * @memberOf R
  9. * @since v0.7.0
  10. * @category Function
  11. * @sig (*... -> a) -> [*] -> a
  12. * @param {Function} fn The function which will be called with `args`
  13. * @param {Array} args The arguments to call `fn` with
  14. * @return {*} result The result, equivalent to `fn(...args)`
  15. * @see R.call, R.unapply
  16. * @example
  17. *
  18. * const nums = [1, 2, 3, -99, 42, 6, 7];
  19. * R.apply(Math.max, nums); //=> 42
  20. * @symb R.apply(f, [a, b, c]) = f(a, b, c)
  21. */
  22. var apply =
  23. /*#__PURE__*/
  24. _curry2(function apply(fn, args) {
  25. return fn.apply(this, args);
  26. });
  27. export default apply;