https://github.com/blakek/is-promise
✅ check if a value is Promise-like
https://github.com/blakek/is-promise
Last synced: about 2 months ago
JSON representation
✅ check if a value is Promise-like
- Host: GitHub
- URL: https://github.com/blakek/is-promise
- Owner: blakek
- License: mit
- Created: 2020-09-24T19:17:25.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2020-11-23T15:59:52.000Z (over 5 years ago)
- Last Synced: 2025-11-01T18:21:40.448Z (9 months ago)
- Language: JavaScript
- Size: 86.9 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# @blakek/is-promise
> ✅ check if a value is Promise-like
Sometimes it makes sense to treat Promises and non-Promises differently. For
example, it can be helpful to only return a Promise if given a Promise. This
package helps with that.
If just checking to call `.then()`, you may be wanting to use the built-in
`Promise.resolve()`.
## Install
Using [Yarn]:
```bash
$ yarn add @blakek/is-promise
```
…or using [npm]:
```bash
$ npm i --save @blakek/is-promise
```
## Usage
```js
import { isPromise } from '@blakek/is-promise';
isPromise('test'); //» false
isPromise(Promise.resolve('test')); //» true
isPromise({ then: () => 'non-standard promise' }); //» true
```
## Contributing
[Node.js] and [Yarn] are required to work with this project.
To install all dependencies, run:
```bash
yarn
```
### Useful Commands
| | |
| ------------------- | ----------------------------------------------- |
| `yarn build` | Builds the project to `./dist` |
| `yarn format` | Format the source following the Prettier styles |
| `yarn test` | Run project tests |
| `yarn test --watch` | Run project tests, watching for file changes |
## License
MIT
[node.js]: https://nodejs.org/
[npm]: https://npmjs.com/
[yarn]: https://yarnpkg.com/en/docs/