UNPKG

topkat-utils

Version:

A comprehensive collection of TypeScript/JavaScript utility functions for common programming tasks. Includes validation, object manipulation, date handling, string formatting, and more. Zero dependencies, fully typed, and optimized for performance.

13 lines (12 loc) 910 B
/** Allow to perform async functions in a defined order * This adds the callback to a queue and is resolved when ALL previous callbacks with same name are executed * Use it like: await transaction('nameOfTheFlow', async () => { ...myFunction }) * @param {String|Function} name name for the actions that should never happen concurrently * @param {Function} asyncCallback * @param {Number} timeout default: 120000 (120s) will throw an error if transaction time is higher that this amount of ms * @returns {Promise} */ export declare function transaction(name: any, asyncCallback: any, timeout?: number, doNotThrow?: boolean): Promise<unknown>; export declare function removeItemFromQueue(name: any): Promise<void>; /** Wait for a transaction to complete without creating a new transaction */ export declare function waitForTransaction(transactionName: any, forceReleaseInSeconds?: number): Promise<void>;