partialRight.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. var createPartial = require('../internal/createPartial');
  2. /** Used to compose bitmasks for wrapper metadata. */
  3. var PARTIAL_RIGHT_FLAG = 64;
  4. /**
  5. * This method is like `_.partial` except that partially applied arguments
  6. * are appended to those provided to the new function.
  7. *
  8. * The `_.partialRight.placeholder` value, which defaults to `_` in monolithic
  9. * builds, may be used as a placeholder for partially applied arguments.
  10. *
  11. * **Note:** This method does not set the "length" property of partially
  12. * applied functions.
  13. *
  14. * @static
  15. * @memberOf _
  16. * @category Function
  17. * @param {Function} func The function to partially apply arguments to.
  18. * @param {...*} [partials] The arguments to be partially applied.
  19. * @returns {Function} Returns the new partially applied function.
  20. * @example
  21. *
  22. * var greet = function(greeting, name) {
  23. * return greeting + ' ' + name;
  24. * };
  25. *
  26. * var greetFred = _.partialRight(greet, 'fred');
  27. * greetFred('hi');
  28. * // => 'hi fred'
  29. *
  30. * // using placeholders
  31. * var sayHelloTo = _.partialRight(greet, 'hello', _);
  32. * sayHelloTo('fred');
  33. * // => 'hello fred'
  34. */
  35. var partialRight = createPartial(PARTIAL_RIGHT_FLAG);
  36. // Assign default placeholders.
  37. partialRight.placeholder = {};
  38. module.exports = partialRight;