Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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
- Host: GitHub
- URL: https://github.com/sindresorhus/p-is-promise
- Owner: sindresorhus
- License: mit
- Created: 2016-11-26T08:19:50.000Z (almost 8 years ago)
- Default Branch: main
- Last Pushed: 2021-04-16T07:02:44.000Z (over 3 years ago)
- Last Synced: 2024-05-19T14:01:06.326Z (6 months ago)
- Language: JavaScript
- Size: 12.7 KB
- Stars: 46
- Watchers: 6
- Forks: 9
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- Funding: .github/funding.yml
- License: license
- Security: .github/security.md
Awesome Lists containing this project
- promise-fun - p-is-promise
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('π¦'));
//=> trueisPromise(Bluebird.resolve('π¦'));
//=> trueisPromise('π¦');
//=> 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.