Function: isPromiseLike()
isPromiseLike(
target):boolean
Tell whether a value is promise-like: a thenable, an object or a function with a then method, which await waits for (a Promise included). The then method is not called. Use isPromise for the real promises only.
Parameters
target
any
The value to test, of any type.
Returns
boolean
true when the value has a then method, false otherwise (null and undefined included).
Example
typescript
import {isPromiseLike} from 'lakutata/utils'
console.log(isPromiseLike(Promise.resolve(1)), isPromiseLike({then: (): void => undefined}), isPromiseLike(null))
//true true false