asyncinterval2
How to use:
const Asyncinterval = //Create an asyncintervalObject objectlet interval = async funcoptions; //Start the intervalintervalstartdelay; //Stop the interval;await interval;
Params:
-
func: a function with Promise return;
-
options:
- time: interval time;
- name: name of the job;
- timeout: timeout of each job;
- timeoutCallback: callback if the job has been timeout;
- log: log level,can be "info":every job info, "error": if error occurred.
-
delay: delay milliseconds to start the job
-
wait: if true, will wait till job finished of timeout.
Example:
const Asyncinterval = let options = time: 500 name: "mytester" timeout: 5000 { console; //to something } log: "info" let { return { //job example ; }} let myInterval = job options; myIntervalstart100; // stop() test here:// setTimeout(async ()=>{// console.log(await myInterval.stop(true));// },2000);