1 var createWrap = require('./_createWrap');
3 /** Used to compose bitmasks for function metadata. */
4 var WRAP_CURRY_FLAG = 8;
7 * Creates a function that accepts arguments of `func` and either invokes
8 * `func` returning its result, if at least `arity` number of arguments have
9 * been provided, or returns a function that accepts the remaining `func`
10 * arguments, and so on. The arity of `func` may be specified if `func.length`
13 * The `_.curry.placeholder` value, which defaults to `_` in monolithic builds,
14 * may be used as a placeholder for provided arguments.
16 * **Note:** This method doesn't set the "length" property of curried functions.
22 * @param {Function} func The function to curry.
23 * @param {number} [arity=func.length] The arity of `func`.
24 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
25 * @returns {Function} Returns the new curried function.
28 * var abc = function(a, b, c) {
32 * var curried = _.curry(abc);
43 * // Curried with placeholders.
44 * curried(1)(_, 3)(2);
47 function curry(func, arity, guard) {
48 arity = guard ? undefined : arity;
49 var result = createWrap(func, WRAP_CURRY_FLAG, undefined, undefined, undefined, undefined, undefined, arity);
50 result.placeholder = curry.placeholder;
54 // Assign default placeholders.
55 curry.placeholder = {};
57 module.exports = curry;