@blakek/is-promise
v1.0.0
Published
✅ check if a value is Promise-like
Maintainers
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:
$ yarn add @blakek/is-promise…or using npm:
$ npm i --save @blakek/is-promiseUsage
import { isPromise } from '@blakek/is-promise';
isPromise('test'); //» false
isPromise(Promise.resolve('test')); //» true
isPromise({ then: () => 'non-standard promise' }); //» trueContributing
Node.js and Yarn are required to work with this project.
To install all dependencies, run:
yarnUseful 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
