waited-queue

1.0.0 • Public • Published

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.

Dependencies (0)

    Dev Dependencies (0)

      Package Sidebar

      Install

      npm i waited-queue

      Weekly Downloads

      0

      Version

      1.0.0

      License

      ISC

      Unpacked Size

      3.86 kB

      Total Files

      5

      Last publish

      Collaborators

      • inceabdullah