@urban/is-promise

0.1.0 • Public • Published

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.

Readme

Keywords

Package Sidebar

Install

npm i @urban/is-promise

Weekly Downloads

3

Version

0.1.0

License

MIT

Last publish

Collaborators

  • urban