Big update!Introducing GitHub Bot Commands. Learn more
Socket
Log inBook a demo

is-promise

Package Overview
Dependencies
0
Maintainers
2
Versions
9
Issues
File Explorer

Advanced tools

is-promise

Test whether an object looks like a promises-a+ promise

    4.0.0latest

Version published
Maintainers
2
Weekly downloads
9,475,434
decreased by-11.81%

Weekly downloads

Changelog

Source

4.0.0

Breaking Changes

  • Use PromiseLike instead of Promise in TypeScript (#40)

    This is only a breaking change for TypeScript users.

    In the following code:

    function foo(x: PromiseLike<string> | string) { if (isPromise(x)) { return x; } else { return Promise.resolve(x); } }

    TypeScript would previously have incorrectly inferred foo as returning Promisestring>when in fact it returnsPromiseLikestring>. The latest version fixes this. If you instead had the following code, it should work exactly the same as before:

    function foo(x: Promise<string> | string) { if (isPromise(x)) { return x; } else { return Promise.resolve(x); } }

    This update is to reflect the fact that is-promise does "duck" typing, rather than an instanceof check.

Readme

Source

is-promise

Test whether an object looks like a promises-a+ promise

Build Status Dependency Status NPM version

Installation

$ npm install is-promise

You can also use it client side via npm.

API

import isPromise from 'is-promise'; isPromise(Promise.resolve());//=>true isPromise({then:function () {...}});//=>true isPromise(null);//=>false isPromise({});//=>false isPromise({then: true})//=>false

License

MIT

FAQs

What is is-promise?

Test whether an object looks like a promises-a+ promise

Is is-promise popular?

The npm package is-promise receives a total of 8,989,481 weekly downloads. As such, is-promise popularity was classified as popular.

Is is-promise well maintained?

We found that is-promise demonstrated a not healthy version release cadence and project activity because the last version was released a year ago.It has 2 open source maintainers collaborating on the project.

Last updated on 27 Apr 2020

Did you know?

Socket installs a Github app to automatically flag issues on every pull request and report the health of your dependencies. Find out what is inside your node modules and prevent malicious activity before you update the dependencies.

Install Socket
Socket

Product

Subscribe to our newsletter

Get open source security insights delivered straight into your inbox. Be the first to learn about new features and product updates.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc