@cc-heart/utils
Version:
🔧 javascript common tools collection
34 lines (33 loc) • 1.78 kB
TypeScript
import type { Fn } from '../helper';
export declare function executeConcurrency(tasks: Array<Fn>, maxConcurrency: number): Promise<any[] | null>;
/**
* Invokes a queue.
* @param {Array.<function(...any): any>} taskArray - An array of tasks to be executed.
* @returns {Promise<void>} - A promise that resolves when all tasks are completed.
*/
export declare function executeQueue(taskArray: Array<(...args: any) => any>): Promise<void>;
/**
* Takes a series of functions and returns a new function that runs these functions in sequence.
* If a function returns a Promise, the next function is called with the resolved value.
*
* @param fns - The functions to pipe.
* @returns A new function that takes any number of arguments and pipes them through `fns`.
*/
export declare function pipe(...fns: Array<Fn>): (...args: any[]) => any;
/**
* Takes a series of functions and returns a new function that runs these functions in reverse sequence.
* If a function returns a Promise, the next function is called with the resolved value.
*
* @param fns - The functions to compose.
* @returns A new function that takes any number of arguments and composes them through `fns`.
*/
export declare function compose(...fns: Array<Fn>): (...args: any[]) => any;
/**
* Executes a given function repeatedly at a specified interval using setTimeout and clearTimeout.
*
* @param func - The function to be executed.
* @param delay - The interval (in milliseconds) at which the function should be executed.
* @returns A function that, when called, clears the interval and stops the execution of the given function.
*/
export declare function setintervalByTimeout(func: Function, delay: number): () => void;
export declare const setIntervalByTimeout: typeof setintervalByTimeout;