1c5e8a5fb41ea737897ac7a64f0053edfab9519e
[yaffs-website] / node_modules / grunt-legacy-log-utils / node_modules / lodash / curry.js
1 var createWrapper = require('./_createWrapper');
2
3 /** Used to compose bitmasks for wrapper metadata. */
4 var CURRY_FLAG = 8;
5
6 /**
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`
11  * is not sufficient.
12  *
13  * The `_.curry.placeholder` value, which defaults to `_` in monolithic builds,
14  * may be used as a placeholder for provided arguments.
15  *
16  * **Note:** This method doesn't set the "length" property of curried functions.
17  *
18  * @static
19  * @memberOf _
20  * @category Function
21  * @param {Function} func The function to curry.
22  * @param {number} [arity=func.length] The arity of `func`.
23  * @param- {Object} [guard] Enables use as an iteratee for functions like `_.map`.
24  * @returns {Function} Returns the new curried function.
25  * @example
26  *
27  * var abc = function(a, b, c) {
28  *   return [a, b, c];
29  * };
30  *
31  * var curried = _.curry(abc);
32  *
33  * curried(1)(2)(3);
34  * // => [1, 2, 3]
35  *
36  * curried(1, 2)(3);
37  * // => [1, 2, 3]
38  *
39  * curried(1, 2, 3);
40  * // => [1, 2, 3]
41  *
42  * // Curried with placeholders.
43  * curried(1)(_, 3)(2);
44  * // => [1, 2, 3]
45  */
46 function curry(func, arity, guard) {
47   arity = guard ? undefined : arity;
48   var result = createWrapper(func, CURRY_FLAG, undefined, undefined, undefined, undefined, undefined, arity);
49   result.placeholder = curry.placeholder;
50   return result;
51 }
52
53 // Assign default placeholders.
54 curry.placeholder = {};
55
56 module.exports = curry;