Skip to content

isPromise

The isPromise function checks if the provided value is a Promise.

Syntax

typescript
isPromise<T = any>(value: any): value is Promise<T>;

Parameters

ParameterTypeDescription
valueanyValue to be checked

Returns

TypeDescription
booleanTrue if it is a Promise

Examples

typescript
isPromise(Promise.resolve(123)); // => true
isPromise(123); // => false

Notes

  • Useful for validation before using then/catch/finally.

References

Released under the MIT License.