Gathering detailed insights and metrics for @node-ipc/js-queue
Gathering detailed insights and metrics for @node-ipc/js-queue
Gathering detailed insights and metrics for @node-ipc/js-queue
Gathering detailed insights and metrics for @node-ipc/js-queue
@achrinza/node-ipc
A nodejs module for local and remote Inter Process Communication (IPC), Neural Networking, and able to facilitate machine learning.
node-ipc
A nodejs module for local and remote Inter Process Communication (IPC), Neural Networking, and able to facilitate machine learning.
web3-providers-ipc
IPC provider for Web3 4.x.x
queue-microtask
fast, tiny `queueMicrotask` shim for modern engines
npm install @node-ipc/js-queue
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
1 Stars
28 Commits
1 Watching
1 Branches
4 Contributors
Updated on 28 May 2022
JavaScript (100%)
Cumulative downloads
Total Downloads
Last day
-1.7%
101,923
Compared to previous day
Last week
1.5%
527,048
Compared to previous week
Last month
8.6%
2,242,354
Compared to previous month
Last year
-10.3%
28,024,634
Compared to previous year
1
Works great in node.js, webpack, browserify, or any other commonjs loader or compiler. To use in plain old vanilla browser javascript without common js just replace the requires in the examples with script tags. We show that below too.
js-queue
also exposes the easy-stack
stack via require('js-queue/stack.js')
this file exposes an ES6 stack which allows for Last In First Out (LIFO) queuing. This can come in handy depending on your application needs, check out the easy-stack javascript documentation it follows the js-queue
interface but is node 6 or greater as it uses ES6 classes.
npm install js-queue
npm info : See npm trends and stats for js-queue
GitHub info :
Package details websites :
This work is licenced via the MIT Licence.
key | type | paramaters | default | description |
---|---|---|---|---|
add | function | any number of functions | adds all parameter functions to queue and starts execution if autoRun is true, queue is not already running and queue is not forcibly stopped | |
next | function | executes next item in queue if queue is not forcibly stopped | ||
clear | function | removes remaining items in the queue | ||
contents | Array | Queue instance contents | ||
autoRun | Bool | true | should autoRun queue when new item added | |
stop | Bool | false | setting this to true will forcibly prevent the queue from executing |
1 2 var Queue=require('js-queue'); 3 //create a new queue instance 4 var queue=new Queue; 5 6 for(var i=0; i<50; i++){ 7 //add a bunch of stuff to the queue 8 queue.add(makeRequest); 9 } 10 11 function makeRequest(){ 12 //do stuff 13 console.log('making some request'); 14 15 this.next(); 16 } 17
The only difference is including via a script tag instead of using require.
1 2 <html> 3 <head> 4 <!-- this is the only difference --> 5 <script src='./queue-vanilla.js'></script> 6 <script> 7 console.log('my awesome app script'); 8 var queue=new Queue; 9 10 for(var i=0; i<50; i++){ 11 queue.add(makeRequest); 12 } 13 14 function makeRequest(){ 15 console.log('making some request'); 16 17 this.next(); 18 } 19 </script> 20 </head> 21 <body> 22 </body> 23 </html> 24
This allows you to start adding requests immediately and only execute if the websocket is connected. To use in plain browser based JS without webpack or browserify just replace the requires with the script tag.
1 2 var Queue=require('js-queue'); 3 4 //ws-share just makes it easier to share websocket code and ensure you don't open a websocket more than once 5 var WS=require('ws-share'); 6 7 //js-message makes it easy to create and parse normalized JSON messages. 8 var Message=require('js-message'); 9 10 //create a new queue instance 11 var queue=new Queue; 12 13 //force stop until websocket opened 14 queue.stop=true; 15 16 var ws=null; 17 18 function startWS(){ 19 //websocket.org rocks 20 ws=new WS('wss://echo.websocket.org/?encoding=text'); 21 22 ws.on( 23 'open', 24 function(){ 25 ws.on( 26 'message', 27 handleResponse 28 ); 29 30 //now that websocket is opened allow auto execution 31 queue.stop=false; 32 queue.next(); 33 } 34 ); 35 36 ws.on( 37 'error', 38 function(err){ 39 //stop execution of queue if there is an error because the websocket is likely closed 40 queue.stop=true; 41 //remove remaining items in the queue 42 queue.clear(); 43 throw(err); 44 } 45 ); 46 47 ws.on( 48 'close', 49 function(){ 50 //stop execution of queue when the websocket closed 51 queue.stop=true; 52 } 53 ); 54 } 55 56 //simulate a lot of requests being queued up for the websocket 57 for(var i=0; i<50; i++){ 58 queue.add(makeRequest); 59 } 60 61 var messageID=0; 62 63 function handleResponse(e){ 64 var message=new Message; 65 message.load(e.data); 66 67 console.log(message.type,message.data); 68 } 69 70 function makeRequest(){ 71 messageID++; 72 var message=new Message; 73 message.type='testMessage'; 74 message.data=messageID; 75 76 ws.send(message.JSON); 77 78 this.next(); 79 } 80 81 startWS(); 82
1 2 var Queue=require('js-queue'); 3 4 //MyAwesomeQueue inherits from Queue 5 MyAwesomeQueue.prototype = new Queue; 6 //Constructor will extend Queue 7 MyAwesomeQueue.prototype.constructor = MyAwesomeQueue; 8 9 function MyAwesomeQueue(){ 10 //extend with some stuff your app needs, 11 //maybe npm publish your extention with js-queue as a dependancy? 12 Object.defineProperties( 13 this, 14 { 15 isStopped:{ 16 enumerable:true, 17 get:checkStopped, 18 set:checkStopped 19 }, 20 removeThirdItem:{ 21 enumerable:true, 22 writable:false, 23 value:removeThird 24 } 25 } 26 ); 27 28 //enforce Object.assign for extending by locking down Class structure 29 //no willy nilly cowboy coding 30 Object.seal(this); 31 32 function checkStopped(){ 33 return this.stop; 34 } 35 36 function removeThird(){ 37 //get the queue content 38 var list=this.contents; 39 //modify the queue content 40 list.splice(2,1); 41 //save the modified queue content 42 this.contents=list; 43 44 return this.contents; 45 } 46 } 47
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
0 existing vulnerabilities detected
Reason
Found 0/28 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no SAST tool detected
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Score
Last Scanned on 2024-11-18
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More