curryRight.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. var createCurry = require('../internal/createCurry');
  2. /** Used to compose bitmasks for wrapper metadata. */
  3. var CURRY_RIGHT_FLAG = 16;
  4. /**
  5. * This method is like `_.curry` except that arguments are applied to `func`
  6. * in the manner of `_.partialRight` instead of `_.partial`.
  7. *
  8. * The `_.curryRight.placeholder` value, which defaults to `_` in monolithic
  9. * builds, may be used as a placeholder for provided arguments.
  10. *
  11. * **Note:** This method does not set the "length" property of curried functions.
  12. *
  13. * @static
  14. * @memberOf _
  15. * @category Function
  16. * @param {Function} func The function to curry.
  17. * @param {number} [arity=func.length] The arity of `func`.
  18. * @param- {Object} [guard] Enables use as a callback for functions like `_.map`.
  19. * @returns {Function} Returns the new curried function.
  20. * @example
  21. *
  22. * var abc = function(a, b, c) {
  23. * return [a, b, c];
  24. * };
  25. *
  26. * var curried = _.curryRight(abc);
  27. *
  28. * curried(3)(2)(1);
  29. * // => [1, 2, 3]
  30. *
  31. * curried(2, 3)(1);
  32. * // => [1, 2, 3]
  33. *
  34. * curried(1, 2, 3);
  35. * // => [1, 2, 3]
  36. *
  37. * // using placeholders
  38. * curried(3)(1, _)(2);
  39. * // => [1, 2, 3]
  40. */
  41. var curryRight = createCurry(CURRY_RIGHT_FLAG);
  42. // Assign default placeholders.
  43. curryRight.placeholder = {};
  44. module.exports = curryRight;