Returns true if the value is a Promise or has a `then` method.
isPromise(Promise.resolve(1)); // => trueisPromise({ then() {} }); // => trueisPromise(1); // => false
npx atmx add helper is-promise
Copy and paste the following method into @/utils/helpers/undefined.ts:
@/utils/helpers/undefined.ts
import { isFunction } from "@/helpers/is-function.ts"; /*** Returns true if the value is a Promise or has a `then` method.** @example* isPromise(Promise.resolve(1)) // => true* isPromise({ then() {} }) // => true* isPromise(1) // => false*/export function isPromise(value: any): value is Promise<any> {return !!value && isFunction(value.then);}