Tests whether an Object is a promise/A+ promise.
npm i @urban/is-promise
import isPromise from '@urban/is-promise'
function noop () {}
const promise = new Promise(noop, noop)
const promiseLookalike = { then: function () {} }
function * gen () {}
isPromise(promise) // => true
isPromise(promiseLookalike) // => true
isPromise(gen) // => false
isPromise(null) // => false
isPromise(undefined) // => false
isPromise(noop) // => false
isPromise([]) // => false
isPromise({}) // => false
isPromise('str') // => false
The MIT License (MIT). Copyright (c) Urban Faubion.