|
Last change
on this file since ba17441 was a762898, checked in by istevanoska <ilinastevanoska@…>, 5 months ago |
|
Added visualizations
|
-
Property mode
set to
100644
|
|
File size:
766 bytes
|
| Line | |
|---|
| 1 | /**
|
|---|
| 2 | * Creates a function that invokes func, with up to `n` arguments, ignoring any additional arguments.
|
|---|
| 3 | * If `n` is not provided, it defaults to the function's length.
|
|---|
| 4 | *
|
|---|
| 5 | * @param {Function} func - The function to cap arguments for.
|
|---|
| 6 | * @param {number} [n] - The arity cap. Defaults to func.length.
|
|---|
| 7 | * @returns {Function} Returns the new capped function.
|
|---|
| 8 | *
|
|---|
| 9 | * @example
|
|---|
| 10 | * function fn(a: number, b: number, c: number) {
|
|---|
| 11 | * return Array.from(arguments);
|
|---|
| 12 | * }
|
|---|
| 13 | *
|
|---|
| 14 | * // Cap at 2 arguments
|
|---|
| 15 | * const capped = ary(fn, 2);
|
|---|
| 16 | * capped(1, 2, 3); // [1, 2]
|
|---|
| 17 | *
|
|---|
| 18 | * // Default to function length
|
|---|
| 19 | * const defaultCap = ary(fn);
|
|---|
| 20 | * defaultCap(1, 2, 3); // [1, 2, 3]
|
|---|
| 21 | */
|
|---|
| 22 | declare function ary(func: (...args: any[]) => any, n?: number): (...args: any[]) => any;
|
|---|
| 23 |
|
|---|
| 24 | export { ary };
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.