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.

34 lines
889 B

4 years ago
  1. import _curry1 from "./internal/_curry1.js";
  2. /**
  3. * Takes a function `fn`, which takes a single array argument, and returns a
  4. * function which:
  5. *
  6. * - takes any number of positional arguments;
  7. * - passes these arguments to `fn` as an array; and
  8. * - returns the result.
  9. *
  10. * In other words, `R.unapply` derives a variadic function from a function which
  11. * takes an array. `R.unapply` is the inverse of [`R.apply`](#apply).
  12. *
  13. * @func
  14. * @memberOf R
  15. * @since v0.8.0
  16. * @category Function
  17. * @sig ([*...] -> a) -> (*... -> a)
  18. * @param {Function} fn
  19. * @return {Function}
  20. * @see R.apply
  21. * @example
  22. *
  23. * R.unapply(JSON.stringify)(1, 2, 3); //=> '[1,2,3]'
  24. * @symb R.unapply(f)(a, b) = f([a, b])
  25. */
  26. var unapply =
  27. /*#__PURE__*/
  28. _curry1(function unapply(fn) {
  29. return function () {
  30. return fn(Array.prototype.slice.call(arguments, 0));
  31. };
  32. });
  33. export default unapply;