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

basic-work-queue

v1.1.0

Published

A basic queue for managing workflows

Downloads

12

Readme

Build Status npm FOSSA Status

Description

:tada::tada: Check out what's new in 1.1.0 https://github.com/tastypackets/basic-work-queue/releases/latest

This is a basic queue, it is essentially an array with some additional methods to make it easier to control work flow. Since it is an array with no validation it allows the developer to put whatever they want in it, from strings to nested arrays.

The queue can be initialized with an array and a call back that will execute whenever an op is attempted while the queue is frozen. The call back will receive the queue as the first and only variable its passed, this was done as convenience in case any form of logging was needed or perhaps a simple way of pausing data streams. This call back is set at the class level and is not intended to be set separately by every queue op.

The queue methods all return false if the queue is frozen, so handling of individual operations / retrying an operation should be done based on the response from the method not using the call back.

The project is documented with jsdoc and all the documentation can be found on the github page: https://tastypackets.github.io/basic-work-queue/

Setup

Install

yarn add basic-work-queue or npm install --save basic-work-queue

Import

const BasicQueue = require('basic-work-queue');

Construction

Basic operation examples, see the API documentation for full detials. https://tastypackets.github.io/basic-work-queue/

// A new empty queue
let myQueue = new BasicQueue();

// A new queue with a default array of values
myQueue = new BasicQueue([1,2,3]);

// A new queue with a default array and a call back to execute when an op is attempted while frozen
myQueue = new BasicQueue([1,2,3], (q) => {
  console.log('Queue is frozen')
  console.log(`The queue size is ${q.queue.length}`)
});

// Add an item
myQueue.add(5); // Queue is now [1,2,3,4,5] - returns true

// Add an item to the beginning of the queue - queue is now [1,2,3,4,5, {text: 'Hello World'}] - returns true
myQueue.addToBeginning({text: 'Hello World'});

// Get next item
const nextItem = myQueue.getNext() // This will return [{text: 'Hello World'}]
const lastItem = myQueue.getLast() // This will return [5]

// Get multiple at once
const next2 = myQueue.getNext(2) // This will return [1,2]

// Remove an item
myQueue.remove(3) // Returns true

Testing

Run the mocha test script to test the library, using yarn it would be yarn test.

License

FOSSA Status