isPromise
Determine if a value is a Promise
Pass in a value and get a boolean telling you if the value is a Promise. This function is not “bullet proof” because determining if a value is a Promise in javascript is not “bullet proof”. The standard/recommended method is to use Promise.resolve to essentially cast any value, promise or not, into an awaited value. However, this may do in a pinch.
API
function isPromise(value: any): value is Promise<any>;
Usage
import { isPromise } from '@feedzai/js-utilities';
isPromise('hello')
// false
isPromise(['hello'])
// false
isPromise(new Promise(res => res()))
// true