@spa-tools/utilities
isPromise()
The isPromise()
function is the epitomy of self-describing :-).
Usage
import { isPromise } from '@spa-tools/utilities';
const promise = new Promise((resolve) => resolve('foo'));
const nonPromise = { foo: 'bar' };
console.log(isPromise(promise));
// --> true
console.log(isPromise(nonPromise));
// --> false
Arguments
Name | Type | Required? | Description |
---|---|---|---|
obj | unkown | yes | The value to check |
Returns
boolean
- If obj
is Promise
then returns true
else returns false
.