dino-core
Version:
A dependency injection framework for NodeJS applications
25 lines (24 loc) • 883 B
TypeScript
export declare class PromiseHelper {
/**
* Validate that the provided object is a promise or not
*
* @param {any} obj the object to be validated as a promise
*
* @static
* @public
*/
static isAPromise(obj: any): boolean;
/**
* Allows to wait for a promise to be resolved or invoke the provided directly if the value is not a promise.
* If the provided value is undefined no action will be taken
*
* @param {Promise | any} value the value to check and process
* @param {Function} callback the callback to invoke when the value is processed,
* the callback will accept a parameter that is the value or the value resolved from the promise
* @returns void
*
* @static
* @public
*/
static handleAsPromiseIfRequired(value: any | Promise<any>, callback: (arg?: any) => void): void;
}