Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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

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)
```