Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/sindresorhus/p-is-promise

Check if something is a promise
https://github.com/sindresorhus/p-is-promise

Last synced: about 1 month ago
JSON representation

Check if something is a promise

Awesome Lists containing this project

README

        

# p-is-promise

> Check if something is a promise

Why not [`is-promise`](https://github.com/then/is-promise)? That module [checks for a thenable](https://github.com/then/is-promise/issues/6), not an ES2015 promise. This one is stricter.

You most likely don't need this. Just pass your value to `Promise.resolve()` and let it handle it.

Can be useful if you need to create a fast path for a synchronous operation.

## Install

```
$ npm install p-is-promise
```

## Usage

```js
import isPromise from 'p-is-promise';
import Bluebird from 'bluebird';

isPromise(Promise.resolve('πŸ¦„'));
//=> true

isPromise(Bluebird.resolve('πŸ¦„'));
//=> true

isPromise('πŸ¦„');
//=> false
```

## Related

- [is](https://github.com/sindresorhus/is) - Type check values
- [More…](https://github.com/sindresorhus/promise-fun)

---



Get professional support for this package with a Tidelift subscription




Tidelift helps make open source sustainable for maintainers while giving companies
assurances about security, maintenance, and licensing for their dependencies.