flouthoc / buha.js

Browser based Strictly ordered Task Queue for Sync/Async Javascript Functions

Home Page:https://flouthoc.github.io/buha.js/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

buha.js

buha.js

Browser based Strictly ordered Task Queue for Sync/Async Javascript Functions. https://flouthoc.github.io/buha.js/

Install

npm i buha

Usage

Both Sync/Async Jobs can be submitted to buhaRunner with simple push function

const buhaRunner = buha();
buhaRunner.push(job1);
buhaRunner.push(job2);

Async Function with Callback example

const exampletask = async (callback) => {

  let promise = new Promise((resolve, reject) => {
    setTimeout(() => resolve("done!"), 1000)
  });

  let result = await promise; // wait till the promise resolves (*)

  alert(result); // "done!"
  callback();
}

const buhaRunner = buha();
buhaRunner(exampletask);

Sync Function with Callback as argument to push not to function itself.

const buhaRunner = buha();
buhaRunner(()=>{console.log("hello"), ()=>{console.log("Quick Callback"}, true);

Docs

.push(job, callback, isSync)

  • Job : main job function
  • Callback: callback if not specifed in function itself
  • isSync: must be true if function is Synchronus.

Contributors

add your name here

Leagal

Any Images or artwork used in this project are part of freepik.

About

Browser based Strictly ordered Task Queue for Sync/Async Javascript Functions

https://flouthoc.github.io/buha.js/

License:MIT License


Languages

Language:JavaScript 100.0%