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.

35 lines
1.1 KiB

4 years ago
  1. import _curry3 from "./internal/_curry3.js";
  2. /**
  3. * `o` is a curried composition function that returns a unary function.
  4. * Like [`compose`](#compose), `o` performs right-to-left function composition.
  5. * Unlike [`compose`](#compose), the rightmost function passed to `o` will be
  6. * invoked with only one argument. Also, unlike [`compose`](#compose), `o` is
  7. * limited to accepting only 2 unary functions. The name o was chosen because
  8. * of its similarity to the mathematical composition operator .
  9. *
  10. * @func
  11. * @memberOf R
  12. * @since v0.24.0
  13. * @category Function
  14. * @sig (b -> c) -> (a -> b) -> a -> c
  15. * @param {Function} f
  16. * @param {Function} g
  17. * @return {Function}
  18. * @see R.compose, R.pipe
  19. * @example
  20. *
  21. * const classyGreeting = name => "The name's " + name.last + ", " + name.first + " " + name.last
  22. * const yellGreeting = R.o(R.toUpper, classyGreeting);
  23. * yellGreeting({first: 'James', last: 'Bond'}); //=> "THE NAME'S BOND, JAMES BOND"
  24. *
  25. * R.o(R.multiply(10), R.add(10))(-4) //=> 60
  26. *
  27. * @symb R.o(f, g, x) = f(g(x))
  28. */
  29. var o =
  30. /*#__PURE__*/
  31. _curry3(function o(f, g, x) {
  32. return f(g(x));
  33. });
  34. export default o;