Ohm-Management - Projektarbeit B-ME
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.

curryRight.js 1.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. var createWrap = require('./_createWrap');
  2. /** Used to compose bitmasks for function metadata. */
  3. var WRAP_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 doesn't set the "length" property of curried functions.
  12. *
  13. * @static
  14. * @memberOf _
  15. * @since 3.0.0
  16. * @category Function
  17. * @param {Function} func The function to curry.
  18. * @param {number} [arity=func.length] The arity of `func`.
  19. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  20. * @returns {Function} Returns the new curried function.
  21. * @example
  22. *
  23. * var abc = function(a, b, c) {
  24. * return [a, b, c];
  25. * };
  26. *
  27. * var curried = _.curryRight(abc);
  28. *
  29. * curried(3)(2)(1);
  30. * // => [1, 2, 3]
  31. *
  32. * curried(2, 3)(1);
  33. * // => [1, 2, 3]
  34. *
  35. * curried(1, 2, 3);
  36. * // => [1, 2, 3]
  37. *
  38. * // Curried with placeholders.
  39. * curried(3)(1, _)(2);
  40. * // => [1, 2, 3]
  41. */
  42. function curryRight(func, arity, guard) {
  43. arity = guard ? undefined : arity;
  44. var result = createWrap(func, WRAP_CURRY_RIGHT_FLAG, undefined, undefined, undefined, undefined, undefined, arity);
  45. result.placeholder = curryRight.placeholder;
  46. return result;
  47. }
  48. // Assign default placeholders.
  49. curryRight.placeholder = {};
  50. module.exports = curryRight;