Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/alsotang/forceinterval
auto execute omitted setInterval cycle
https://github.com/alsotang/forceinterval
Last synced: 13 days ago
JSON representation
auto execute omitted setInterval cycle
- Host: GitHub
- URL: https://github.com/alsotang/forceinterval
- Owner: alsotang
- Created: 2016-08-31T08:03:43.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2016-08-31T09:22:09.000Z (over 8 years ago)
- Last Synced: 2024-12-03T19:03:44.543Z (about 1 month ago)
- Language: JavaScript
- Size: 1.95 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## forceinterval
Auto execute omitted `setInterval` cycle
## install
`npm install forceinterval`
## description
For many webpage, we have some `setInterval` logic in it, but sometimes some heavy compute occurs, then the `setInterval` logic would show wrong result for us. Such as clock chart, or some animation.
`forceInterval` can replace `setInterval` in many scenes seamlessly, and its usecase is common. So I hope this function can be added in lodash.
## example
```js
var forceinterval = require('forceinterval')
var count = 0;forceinterval(function addTask() {
count++;
}, 100)var startTime = +new Date()
while ((new Date - startTime) < 1000) {}setTimeout(function () {
// !!!This is the point. After block,
// forceinterval auto run `addTask` 10 times.
assert(count == 10)
done()
}, 50)
```