UNPKG

@gecut/utilities

Version:

The ultimate utility toolkit from Gecut Company, crafted with TypeScript for optimal speed and efficiency. Designed to boost productivity with a suite of fast and optimized tools.

69 lines (68 loc) 1.99 kB
/** * GecutQueue class */ export declare class GecutQueue { /** * Creates a new GecutQueue instance * @param {string} name - The name of the queue * @param {('animationFrame' | 'idleCallback' | number)} delayPeriod - The delay period for the queue */ constructor(name: string, delayPeriod: 'animationFrame' | 'idleCallback' | number); name: string; private delayPeriod; /** * The queue map * @type {Map<string, Promise<unknown>>} */ private queue; /** * The values map * @type {Map<string, unknown>} */ private values; private runningId?; /** * Pushes a new promise to the queue * @param {Promise<unknown>} promise - The promise to push * @param {string} [id] - The optional id for the promise * @returns {{ id: string }} - The id of the pushed promise */ push( promise: Promise<unknown>, id?: string, ): { id: string; }; /** * Gets the value of a promise * @param {string} id - The id of the promise * @returns {Promise<unknown>} - The promise value */ getValue<T>(id: string): T | Promise<T>; /** * Checks if a promise is running * @param {string} id - The id of the promise * @returns {boolean} - Whether the promise is running */ isRunning(id: string): boolean; isFinished(id: string): boolean; /** * Waits for a promise to finish * @param {string} id - The id of the promise * @returns {Promise<unknown>} - The promise result */ waitForFinish(id: string): Promise<unknown>; /** * Waits for all promises to finish * @returns {Promise<unknown[]>} - The promise results */ waitForAllFinish(): Promise<unknown[]>; /** * Gets the delay period function based on the delay period type * @private * @param {('animationFrame' | 'idleCallback' | number)} delayPeriod - The delay period type * @returns {() => Promise<unknown>} - The delay period function */ private getDelayPeriodFunction; } //# sourceMappingURL=queue.d.ts.map