https://github.com/imcuttle/interval-check
Polling check by intervally
https://github.com/imcuttle/interval-check
Last synced: about 1 year ago
JSON representation
Polling check by intervally
- Host: GitHub
- URL: https://github.com/imcuttle/interval-check
- Owner: imcuttle
- License: mit
- Created: 2020-08-31T09:19:49.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2022-01-07T14:16:10.000Z (over 4 years ago)
- Last Synced: 2025-03-23T02:34:01.924Z (about 1 year ago)
- Language: TypeScript
- Size: 104 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: License
Awesome Lists containing this project
README
# interval-check
[](https://travis-ci.org/imcuttle/interval-check)
[](https://codecov.io/github/imcuttle/interval-check?branch=master)
[](https://www.npmjs.com/package/interval-check)
[](https://www.npmjs.com/package/interval-check)
[](https://prettier.io/)
[](https://conventionalcommits.org)
> Polling check by intervally
## Installation
```bash
npm install interval-check
# or use yarn
yarn add interval-check
```
## API
### setIntervalCheck
#### Parameters
- `fn` {Function}
- `shouldStop` {() => boolean | Promise}
- `interval` {number}
#### Examples
```javascript
import setIntervalCheck from 'interval-check'
let data
fetch('/data').then((res) => {
data = res
})
const dispose = setIntervalCheck(
() => {
console.log('fetching /data')
},
() => !!data,
1000
)
```
Returns **[Function](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function)**
## Contributing
- Fork it!
- Create your new branch:
`git checkout -b feature-new` or `git checkout -b fix-which-bug`
- Start your magic work now
- Make sure npm test passes
- Commit your changes:
`git commit -am 'feat: some description (close #123)'` or `git commit -am 'fix: some description (fix #123)'`
- Push to the branch: `git push`
- Submit a pull request :)
## Authors
This library is written and maintained by imcuttle, moyuyc95@gmail.com.
## License
MIT - [imcuttle](https://github.com/imcuttle) 🐟