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.2 KiB

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