source: node_modules/es-toolkit/dist/function/spread.d.ts

Last change on this file was a762898, checked in by istevanoska <ilinastevanoska@…>, 5 months ago

Added visualizations

  • Property mode set to 100644
File size: 790 bytes
Line 
1/**
2 * Creates a new function that spreads elements of an array argument into individual arguments
3 * for the original function.
4 *
5 * @template F - A function type with any number of parameters and any return type.
6 * @param {F} func - The function to be transformed. It can be any function with any number of arguments.
7 * @returns {(argsArr: Parameters<F>) => ReturnType<F>} - A new function that takes an array of arguments and returns the result of calling the original function with those arguments.
8 *
9 * @example
10 * function add(a, b) {
11 * return a + b;
12 * }
13 *
14 * const spreadAdd = spread(add);
15 * console.log(spreadAdd([1, 2])); // Output: 3
16 */
17declare function spread<F extends (...args: any[]) => any>(func: F): (argsArr: Parameters<F>) => ReturnType<F>;
18
19export { spread };
Note: See TracBrowser for help on using the repository browser.