Skip to content

urban/is-promise

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

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

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published