Skip to content

toPromise

Normalization any input as a promise. If the input is a function, call it.

Type Declarations

Details
ts
/**
 * Normalization any input as a promise.
 *
 * If the input is a function, call it.
 *
 * @example
 * ```ts
 * expect(await toPromise('hi')).toBe('hi')
 * expect(await toPromise(1)).toBe(1)
 * expect(await toPromise(Promise.resolve(1))).toBe(1)
 * expect(await toPromise(() => 1)).toBe(1)
 * expect(await toPromise(async () => 1)).toBe(1)
 * ```
 *
 * @see {@link https://s3xysteak.github.io/fnclip/functions/promise/toPromise/}
 */
export declare function toPromise<T>(param: (T | PromiseLike<T>) | ((...args: any[]) => T | PromiseLike<T>)): Promise<T>;

Source

Source