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
1.1 KiB

4 years ago
  1. import _concat from "./internal/_concat.js";
  2. import _createPartialApplicator from "./internal/_createPartialApplicator.js";
  3. import flip from "./flip.js";
  4. /**
  5. * Takes a function `f` and a list of arguments, and returns a function `g`.
  6. * When applied, `g` returns the result of applying `f` to the arguments
  7. * provided to `g` followed by the arguments provided initially.
  8. *
  9. * @func
  10. * @memberOf R
  11. * @since v0.10.0
  12. * @category Function
  13. * @sig ((a, b, c, ..., n) -> x) -> [d, e, f, ..., n] -> ((a, b, c, ...) -> x)
  14. * @param {Function} f
  15. * @param {Array} args
  16. * @return {Function}
  17. * @see R.partial
  18. * @example
  19. *
  20. * const greet = (salutation, title, firstName, lastName) =>
  21. * salutation + ', ' + title + ' ' + firstName + ' ' + lastName + '!';
  22. *
  23. * const greetMsJaneJones = R.partialRight(greet, ['Ms.', 'Jane', 'Jones']);
  24. *
  25. * greetMsJaneJones('Hello'); //=> 'Hello, Ms. Jane Jones!'
  26. * @symb R.partialRight(f, [a, b])(c, d) = f(c, d, a, b)
  27. */
  28. var partialRight =
  29. /*#__PURE__*/
  30. _createPartialApplicator(
  31. /*#__PURE__*/
  32. flip(_concat));
  33. export default partialRight;