npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@js-cloud/flashq

v1.1.7

Published

A superfast and lightweight Queue (FIFO) implementations in JavaScript.

Downloads

8

Readme

FlashQ: a javascript Queue library

npm CI npm GitHub issues GitHub

FlashQ is a simple to use, blazing fast library which included different implementations of Queue datastructure for perfomance focused applications.

Table of Contents

About

JS Cloud Suite is an open source project developed with an aim to simplify the effort of creating scalable and performance oriented cloud applications. This suite hosts a series of libraries, which can be integrated into any projects to enable cloud capabilities. We currently do not support in house hosted solutions, but with our tools and libraries, you can build customized solutions your own. All you need to have is a simple server setup (in old PCs, laptops, raspberry Pis, AWS EC2, etc).

You can also contribute to this project. Navigate to contribute section to know how.

This library is developed using Node.js and do not support any other frameworks yet. In order to install and use this library you are required to have a working installation of node.js (preferrably latest version).

Installation

Open up a terminal and install this library like this,

npm install @js-cloud/flashq

Modules

FlashQ

Fastest implementation of queue using plain javascript objects. If you want a simpe and fast queue which works in traditional way, FlashQ might be the one for you.

Usage

ES6 import

FlashQ supports treeshaking via es6 modules.

import {FlashQ} from '@js-cloud/flashq'

const fq=new FlashQ(); //if type is unknown
            
            //OR

const fq=new FlashQ<number>(); //if type is known

CommonJS require

FlashQ supports treeshaking via es6 modules.

const {FlashQ} = require('@js-cloud/flashq');

const fq=new FlashQ(); //if type is unknown
            
            //OR

const fq=new FlashQ<number>(); //if type is known
        

Enqueing item

fq.enqueue(1);
fq.enqueue('item');     

Dequeuing item

console.log(fq.dequeue())    //1
console.log(fq.dequeue()); //'item'    

Peek into the queue

fq.enqueue(1);
fq.enqueue('item'); 

console.log(fq.peek())      //1
console.log(fq.dequeue())    //1
    
console.log(fq.peek())      //'item'
console.log(fq.dequeue()); //'item'    

AutoQ

Automatic queue is an extension of FlashQ which automatically call given callbacks when an item in enqueued in the queue. It also has the ability to pause and resume the queue processing. The queue has various states (IDLE, PAUSED, RUNNING), which describes the current state in which the queue is. As soon as the queue recieves first item, it starts processing the queue and starts ejecting items.

  • IDLE -> the queue is empty and will immediately dequeue any incoming request.
  • PAUSED -> the queue is paused and will hold every incoming requesting in FIFO manner (order will be preserved).
  • RUNNING -> the queue is running and will dequeue incoming request sequentially

ES6 import

FlashQ supports treeshaking via es6 modules.

import {AutoQ} from '@js-cloud/flashq'

const aq=new AutoQ(); //if type is unknown
            
            //OR

const aq=new AutoQ<number>(); //if type is known

CommonJS require

FlashQ supports treeshaking via es6 modules.

const {AutoQ} = require('@js-cloud/flashq');

const aq=new AutoQ(); //if type is unknown
            
            //OR

const aq=new AutoQ<number>(); //if type is known
        

Enqueing item

aq.enqueue(1);
aq.enqueue('item');     

Auto dequeing of items

aq.onDequeue((item) => {
    console.log('dequeue event ->', item);

}) 

Pause / Resume Queue

aq.pauseQueue();
aq.resumeQueue();

Dequeuing item manually

console.log(aq.dequeue())    //1
console.log(aq.dequeue()); //'item'    

Peek into the queue

aq.enqueue(1);
aq.enqueue('item'); 

console.log(aq.peek())      //1
console.log(aq.dequeue())    //1
    
console.log(aq.peek())      //'item'
console.log(aq.dequeue()); //'item'    

Contribute

We welcome feedback, bug reports, and pull requests!

For pull requests, please stick to the following guidelines:

  • Add tests for any new features and bug fixes. Ideally, each PR should increase the test coverage.
  • Follow the existing code style. (Run npm run format and npm run lint before checking in your code).
  • Put a reasonable amount of comments into the code.
  • Fork this repo on your GitHub user account, do your changes there and then create a PR against main repository.
  • Separate unrelated changes into multiple pull requests.

Please note that by contributing any code or documentation to this repository (by raising pull requests, or otherwise) you explicitly agree to the.