Skip to main content
@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

NameTypeRequired?Description
objunkownyesThe value to check

Returns

boolean - If obj is Promise then returns true else returns false.