Last change
on this file since e29cc2e was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
857 bytes
|
Line | |
---|
1 | var createWrap = require('./_createWrap');
|
---|
2 |
|
---|
3 | /** Used to compose bitmasks for function metadata. */
|
---|
4 | var 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 | */
|
---|
23 | function 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 |
|
---|
29 | module.exports = ary;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.