0.1.0 • Published 8 years ago

@urban/is-promise v0.1.0

Weekly downloads
1
License
MIT
Repository
github
Last release
8 years ago

is-promise

Tests whether an Object is a promise/A+ promise.

Install

npm i @urban/is-promise

Usage

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

License

The MIT License (MIT). Copyright (c) Urban Faubion.