waited-queue
v1.0.0
Published
Async Queue Push Waited
Downloads
5
Readme
waited-queue
Async Queue Push Waited
stack: [async Func, async Func, ...]
pushFunc(asyncFunc)-----------------------------------
<------1st------------2nd-----------3rd------> V
stack: [async Func, async Func, async Func] +
loop:
1. shift()-------^ t0
v
await 1st async Func()
waiting from t0 until period ms
2. shift()------------------------^ t1
v
await 2nd async Func()
waiting until t1 + period ms
3. shift()--------------------------------------------^ t2
v
await 3rd async Func()
waiting until t2 + period ms
4. shift() => undefined // doing nothing
wating for periodLoop ms
5. shift()
...
Import
$ npm i waited-queue
const { pushFunc } = require("waited-queue");
Config
setPeriodLoop
pushFunc.setPeriodLoop(10);
setPeriod
pushFunc.setPeriod(6000); // 10/min.
pushFunc
const asyncFunc = async () => {
// please use await instead of .then
....
}
pushFunc(asyncFunc);
You can check test.js out.