Security News
New Proposed CISA Mandate Would Require Critical Infrastructure to Report Ransom Payments Within 24 Hours
CISA has proposed a set of new rules that would require critical infrastructure to report cyber incidents and ransom payments.
linked-queue
Advanced tools
Queues using linked list, faster than array.shift(), support enqueue,dequeue,enqueue all, dequeue all, clear, forEach, first, last
Weekly downloads
Readme
When I was using javascript Array and calling array.shift() method to get first element and It was terrible if array contains more than 100,000 elements.
var start = new Date().getTime()
for(var i = 0; i< 100000; i++){
array.shift();
}
var duration = new Date().getTime() - start;// duration is so large, greater than 3 minutes
I used Linked List to improve performance, and apply it for 1000,000 elements.
var start = new Date().getTime()
for(var i = 0; i< 1000000; i++){
queue.dequeue();
}
var duration = new Date().getTime() - start;// duration = 8 for 1000000 elements
var LQueue = require('linked-queue')
var queue = new LQueue()
queue.length === 0 //=> true
queue.enqueue(10)
queue.length //=> 1
queue.first() ; // => 10
queue.last() ; // => 10
queue.enqueueAll([11,12]); // queues elements: 10,11,12
queue.fist(); //=> 10
queue.last();// => 12
queue.length;// => 3
queue.dequeue()// return 10, queus elements: 11,12
queue.forEach(function(data){
console.log(data);
});
//=> print: 11 12
queue.dequeueAll(function(data){
console.log(data);
});
//=> print: 11 12
queue.length //return 0
queue.isEmpty(); //return true;
queue.enqueueAll([1,2]);
queue.length;//return 2
queue.clear();
queue.length// return 0
queue = new LQueue()
queue.enqueue(value)
Push a value on the end.
queue.enqueueAll(array)
Push all values of array on the end of queue.
value = queue.dequeue()
Remove a value off the beginning.
queue.dequeueAll(callbackfn)
Remove all values off the beginning. Each dequeued data will be call by callbackFn(data)
queue.length
return size of queue.
value = deque.forEach(callbackfn)
Get all values of queues without removing. Each data will be call by callbackFn(data)
value = queue.last()
Examine the value of the end without removing it.
value = queue.first()
Examine the value of the beginning without removing it.
queue.clear()
Remove all entries.
I was convinced by a blog posting
FAQs
Queues using linked list, faster than array.shift(), support enqueue,dequeue,enqueue all, dequeue all, clear, forEach, first, last
The npm package linked-queue receives a total of 422 weekly downloads. As such, linked-queue popularity was classified as not popular.
We found that linked-queue demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
CISA has proposed a set of new rules that would require critical infrastructure to report cyber incidents and ransom payments.
Security News
Redis is no longer OSS, breaking its explicit commitment to remain under the BSD 3-Clause License forever. This has angered contributors who are now working to fork the software.
Product
Socket AI now enables 'AI detected potential malware' alerts by default, ensuring users benefit from AI-powered state-of-the-art malware detection without needing to opt-in.