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

@mdaemon/process-queue

v1.2.0

Published

A class for pushing objects to a queue and getting the next object from the queue to be processed

Downloads

14

Readme

Dynamic JSON Badge Static Badge install size Dynamic JSON Badge Node.js CI

@mdaemon/process-queue, A class for pushing objects to a queue and getting the next object from the queue to be processed

Install

$ npm install @mdaemon/process-queue --save

Node CommonJS

    const ProcessQueue = require("@mdaemon/process-queue/dist/processQueue.cjs");

Node Modules

    import ProcessQueue from "@mdaemon/process-queue/dist/processQueue.mjs";

Web

    <script type="text/javascript" src="/path_to_modules/dist/processQueue.umd.js">

Creating a ProcessQueue

  // Define your item type
  interface MyQueueItem {
    id: string | number;
    // other properties...
  }

  // Create a new ProcessQueue
  const queue = new ProcessQueue<MyQueueItem>();

Adding Items to the Queue

  const item: MyQueueItem = { id: '1', /* other properties */ };
  const added = queue.queueItem(item);
  console.log(added); // true if the item was added, false if it was already being processed

Getting the Next Item

  const nextItem = queue.getNextItem();
  if (nextItem) {
    // Process the item
    // ...
    
    // Mark it as done when finished
    queue.doneProcessing(nextItem.id);
  }

Checking Queue Status

  console.log(queue.length()); // Number of items in the queue
  console.log(queue.busy()); // true if any items are being processed
  console.log(queue.processSize()); // Number of items currently being processed

Removing Items

  const removed = queue.removeFromQueue('itemId');
  console.log(removed); // true if the item was removed, false if it wasn't in the queue

Getting All Queue Items

  const allItems = queue.getQueue();
  console.log(allItems); // Array of all items in the queue

API Reference

  queueItem(item: QueueItem): boolean: Adds an item to the queue.

  getNextItem(): QueueItem | null: Retrieves and removes the next item from the queue.

  isProcessing(id: ItemID): boolean: Checks if an item is currently being processed.
  
  doneProcessing(id?: ItemID): void: Marks an item (or all items if no id is provided) as done processing.

  removeFromQueue(id: ItemID): boolean: Removes an item from the queue.

  length(prop?: string, val?: any): number: Returns the number of items in the queue, optionally filtered by a property value.

  busy(): boolean: Checks if any items are currently being processed.

  processSize(): number: Returns the number of items currently being processed.

  getQueue(processing: boolean = false): QueueItem[]: Returns all items in the queue, optionally moving them to the processing state.

License

Published under the LGPL-2.1 license.

Published by MDaemon Technologies, Ltd. Simple Secure Email https://www.mdaemon.com