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.

28 lines
813 B

4 years ago
  1. import _curry1 from "./internal/_curry1.js";
  2. import converge from "./converge.js";
  3. /**
  4. * juxt applies a list of functions to a list of values.
  5. *
  6. * @func
  7. * @memberOf R
  8. * @since v0.19.0
  9. * @category Function
  10. * @sig [(a, b, ..., m) -> n] -> ((a, b, ..., m) -> [n])
  11. * @param {Array} fns An array of functions
  12. * @return {Function} A function that returns a list of values after applying each of the original `fns` to its parameters.
  13. * @see R.applySpec
  14. * @example
  15. *
  16. * const getRange = R.juxt([Math.min, Math.max]);
  17. * getRange(3, 4, 9, -3); //=> [-3, 9]
  18. * @symb R.juxt([f, g, h])(a, b) = [f(a, b), g(a, b), h(a, b)]
  19. */
  20. var juxt =
  21. /*#__PURE__*/
  22. _curry1(function juxt(fns) {
  23. return converge(function () {
  24. return Array.prototype.slice.call(arguments, 0);
  25. }, fns);
  26. });
  27. export default juxt;