@anzerr/think.library

setInterval that works with promises

Usage no npm install needed!

<script type="module">
  import anzerrThinkLibrary from 'https://cdn.skypack.dev/@anzerr/think.library';
</script>

README

Intro

GitHub Actions status | publish

setInterval that waits for promises between ticks.

npm install --save git+https://github.com/anzerr/think.library.git
npm install --save @anzerr/think.library

Example

const Think = require('think.libary');

let wait = () => {
    return new Promise((resolve) => {
        setTimeout(resolve, 1000);
    });
};

let i = 0;
const t = new Think(() => {
    console.log('tick', i);
    if (i > 10) {
        t.stop();
    }
    t.start(); // should do nothing
    i += 1;
    return wait();
}, 100);