New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

vanilla-queues-js

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vanilla-queues-js

create async jobs in queues/threads this can be handle in node, typescript, angular, react, vue, and all js based framework

  • 1.1.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

vanilla-queues-js

create and manage async jobs queues/threads in core javascript or Vanilla JS it can be use any javascript framework like ReactJs, Angular React-Native and VueJs

Please see in the EXAMPLE / DEMO

In TypeScript/React/Angular/VueJs/NodeJs

import * as vanillaQueuesJs from "vanilla-queues-js";

// creating object
let vanilaQue = new vanillaQueuesJs.VanillaQueues<number>(5);

//set your jobs
for (let index = 0; index < 100; index++) {
    //Add into stack
    vanilaQue.addJob((data, counter) => {
        //AJAX CAMOUFLAGE (WAIT FOR RANDOM 1 to 3 SEC)
        setTimeout(() => {
            console.log(data, "------> executed ---->", counter);
            //------
            vanilaQue.jobDone();//MARK AS SINGLE JOB IS DONE AFTER CALL "jobDone()" next job is start
            //-----
        }, Math.floor(Math.random() * 3000) + 1000);
        
    }, index);
}

//When all jobs are done this method notify you...
vanilaQue.isDone(() => {
    console.log("All Jobs are done...");
});
// Execute threads ....
vanilaQue.runJobs();

In Pure-Javascript/Browser based

<script src="../dist/vanilla-queues.js"></script>


<script>
    // creating object
    var vanilaQue = new VanillaQueues<number>(5);

    //set your jobs
    for (var index = 0; index < 100; index++) {
        //Add into stack
        vanilaQue.addJob(function(data, counter){
            //AJAX CAMOUFLAGE (WAIT FOR RANDOM 1 to 3 SEC)
            setTimeout(function(){
                console.log(data, "------> executed ---->", counter);
                vanilaQue.jobDone();
            }, Math.floor(Math.random() * 3000) + 1000);//Math.floor(Math.random() * 2000) +
        }, index);
    }

    vanilaQue.isDone(function() {
        console.log("oeeeeee done...");

    });
    // Execute threads ....
    vanilaQue.runJobs();

</script>

Other Useful Methods

var vanilaQue = new VanillaQueues<number>(5);
  • PAUSE - pause all task and return callback function. vanilaQue.pause(()=>console.log("pause successfully...") ),
  • STOP - Stop all task.vanilaQue.stop()
  • RESUME - Resume pause task, note: only pause tast are only to be resume. vanilaQue.resume()
  • Laps Notification - Notify by callback user define number of jobs complete. vanilaQue.achiveLapsNotification(CALLBACK,10) "10" means notify you when every 10 jobs are done.

Pause

vanilaQue.pause(()=>console.log("pause successfully...");

Laps Notification

Notify by callback user define number of jobs complete. vanilaQue.achiveLapsNotification(CALLBACK,10) "10" means notify you when every 10 jobs are done.

vanilaQue.achiveLapsNotification(()=>{
    console.log("lap achived...");
},10)

Keywords

FAQs

Package last updated on 27 Jun 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc