UNPKG

@typescript-package/queue

Version:

A lightweight TypeScript library for managing various queue and stack structures.

82 lines (81 loc) 2.29 kB
import { State } from "@typescript-package/state"; /** * @description Class designed for asynchronous processing the promises of `void`. * @export * @class Processing * @extends {State<Set<Promise<void>>>} The state for active processing promises, tracking the status of asynchronous operations. */ export declare class Processing extends State<Set<Promise<void>>> { #private; /** * @description Tracks whether there are actively processed promises. * @public * @readonly * @type {boolean} */ get active(): boolean; /** * @description A current number of promises being processed. * @public * @readonly * @type {number} */ get activeCount(): number; /** * @description Returns the first promise from processing. * @public * @readonly * @type {Promise<void>} */ get first(): Promise<void>; /** * @description Returns the last promise from processing. * @public * @readonly * @type {Promise<void>} */ get last(): Promise<void>; /** * Creates a `Processing` object. * @constructor */ constructor(); /** * @description Adds the promise to the processing state. * @public * @param {Promise<void>} promise The promise of `void` to add. * @returns {this} */ add(promise: Promise<void>, remove?: boolean): this; /** * @description Returns `Promise` that waits for the processing completion. * @public * @async * @returns {Promise<void>} */ complete(): Promise<void>; /** * @description Sets the `Processing` to debug state. * @public */ debug(): this; /** * @description Removes the specified promise from the processing state. * @public * @param {Promise<void>} promise * @returns {this} */ delete(promise?: Promise<void>): this; /** * @description Checks whether the `Processing` is active. * @public * @param {?boolean} [expected] An optional `boolean` type value to check the active state. * @returns {boolean} */ isActive(expected?: boolean): boolean; /** * @description Unset the `Processing` from the debug state. * @public */ unDebug(): this; }