|
Last change
on this file was a762898, checked in by istevanoska <ilinastevanoska@…>, 5 months ago |
|
Added visualizations
|
-
Property mode
set to
100644
|
|
File size:
669 bytes
|
| Line | |
|---|
| 1 | /**
|
|---|
| 2 | * Checks if a given value is `Promise`.
|
|---|
| 3 | *
|
|---|
| 4 | * This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `Promise`.
|
|---|
| 5 | *
|
|---|
| 6 | * @param {unknown} value The value to check if it is a `Promise`.
|
|---|
| 7 | * @returns {value is Promise<any>} Returns `true` if `value` is a `Promise`, else `false`.
|
|---|
| 8 | *
|
|---|
| 9 | * @example
|
|---|
| 10 | * const value1 = new Promise((resolve) => resolve());
|
|---|
| 11 | * const value2 = {};
|
|---|
| 12 | * const value3 = 123;
|
|---|
| 13 | *
|
|---|
| 14 | * console.log(isPromise(value1)); // true
|
|---|
| 15 | * console.log(isPromise(value2)); // false
|
|---|
| 16 | * console.log(isPromise(value3)); // false
|
|---|
| 17 | */
|
|---|
| 18 | declare function isPromise(value: unknown): value is Promise<any>;
|
|---|
| 19 |
|
|---|
| 20 | export { isPromise };
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.