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 🙏

© 2026 – Pkg Stats / Ryan Hefner

priorities

v1.0.0

Published

Store variables and data based on their priority.

Readme

Priority List

Store values based on their priorities.

Getting Started

Installing and structure

Install the module via NPM: npm i priorities.
After that you must require this module in any file you'd want to use it in.

const List = require("priorities");
// List is the class. Make an instance of it!
const myList = new List();

The PriorityList is a multi dimensional array based on the value's priorities! Every value has an index and a subIndex. The index starts from 1 while the subIndex starts from 0. The code below is a simple priority list structure.

{
    1: ["First", "Second", "Third"],
    2: "Forth"
}

First's index is 1 and subIndex is 0, making it the value with the highest priority. Forth's index is 2 and subIndex is 0, making it the value with the lowest priority.

The PriorityList class has a lot of useful features on working with priorities. See the documentation for more info.

This storage is NOT persistent

It just stores values in a unique way - it does not save them in a file and then load them up. All data in the priority lists will be lost once the node process is killed.

Examples

Adding a value:

myList.add(1, "First") // We added the value 'First' to the first index of the list. 
myList.add(1, "Second")
myList.add(2, "Third")
myList.add(2, "Forth")
myList.add(3, "Fifth")
myList.add(4, "Sixth")

Removing a value:

myList.remove("First") // We remove 'First' from the list.

Getting values:

myList.getByVal("Second") // {value: "Second", index: 1, subIndex: 0}
myList.getByPos(1) // {value: "Second", index: 1, subIndex: 0} since there is only 1 value in index 1.
myList.add(1, "RealSecond")
myList.getByPos(1, 1) // {value: "RealSecond", index: 1, subIndex: 1} 
myList.find((val, index, subIndex) => val == "Fifth") // {value: "Fifth", index: 1, subIndex: 1}

Working with priorities:

myList.compare("Second", "RealSecond") // Returns: "higher". Because "Second"'s subIndex is smaller than "RealSecond"'s subIndex, so "Second" is a higher priority.
myList.highestOf("Sixth", "Forth", "Second") // Returns: "Second". 
myList.lowestOf("Fifth", "Third", "RealSecond") // Returns: "Fifth"
myList.highest // Returns: Second
myList.lowest // Returns: Sixth

Running the tests

Run the tests by doing npm run test

Documentation

Click here to see the documentation.