Initial commit
[yaffs-website] / node_modules / grunt-contrib-watch / node_modules / lodash / function / ary.js
1 var createWrapper = require('../internal/createWrapper'),
2     isIterateeCall = require('../internal/isIterateeCall');
3
4 /** Used to compose bitmasks for wrapper metadata. */
5 var ARY_FLAG = 128;
6
7 /* Native method references for those with the same name as other `lodash` methods. */
8 var nativeMax = Math.max;
9
10 /**
11  * Creates a function that accepts up to `n` arguments ignoring any
12  * additional arguments.
13  *
14  * @static
15  * @memberOf _
16  * @category Function
17  * @param {Function} func The function to cap arguments for.
18  * @param {number} [n=func.length] The arity cap.
19  * @param- {Object} [guard] Enables use as a callback for functions like `_.map`.
20  * @returns {Function} Returns the new function.
21  * @example
22  *
23  * _.map(['6', '8', '10'], _.ary(parseInt, 1));
24  * // => [6, 8, 10]
25  */
26 function ary(func, n, guard) {
27   if (guard && isIterateeCall(func, n, guard)) {
28     n = undefined;
29   }
30   n = (func && n == null) ? func.length : nativeMax(+n || 0, 0);
31   return createWrapper(func, ARY_FLAG, undefined, undefined, undefined, undefined, n);
32 }
33
34 module.exports = ary;