PageRenderTime 21ms CodeModel.GetById 14ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 1ms

/node_modules/lodash/ary.js

https://bitbucket.org/coleman333/smartsite
JavaScript | 29 lines | 8 code | 3 blank | 18 comment | 2 complexity | 574a2dfabea513e4ab99907a54af57c8 MD5 | raw file
 1var createWrap = require('./_createWrap');
 2
 3/** Used to compose bitmasks for function metadata. */
 4var WRAP_ARY_FLAG = 128;
 5
 6/**
 7 * Creates a function that invokes `func`, with up to `n` arguments,
 8 * ignoring any additional arguments.
 9 *
10 * @static
11 * @memberOf _
12 * @since 3.0.0
13 * @category Function
14 * @param {Function} func The function to cap arguments for.
15 * @param {number} [n=func.length] The arity cap.
16 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
17 * @returns {Function} Returns the new capped function.
18 * @example
19 *
20 * _.map(['6', '8', '10'], _.ary(parseInt, 1));
21 * // => [6, 8, 10]
22 */
23function ary(func, n, guard) {
24  n = guard ? undefined : n;
25  n = (func && n == null) ? func.length : n;
26  return createWrap(func, WRAP_ARY_FLAG, undefined, undefined, undefined, undefined, n);
27}
28
29module.exports = ary;