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

solists

v1.0.1

Published

Self-organizing lists with native Array methods

Downloads

17,513

Readme

Installation

npm install solists

Example

const l = new FrequencyCountSoList(["A", "B", "C", "D", "E"]);
l.includes("D"); // D(1) -> front
l.includes("B"); // B(1) -> #2
l.includes("B"); // B(2) overtakes D
// Result: ["B", "D", "A", "C", "E"]
const l = new KInARowSoList(["A", "B", "C", "D", "E"], { k: 2 });
l.includes("D"); // D: 1st access, no move
l.includes("D"); // D: 2nd access, -> front
l.includes("B"); // B: 1st access, no move
// Result: ["D", "A", "B", "C", "E"]
const l = new MoveAheadKSoList(["A", "B", "C", "D", "E"], { k: 2 });
l.includes("D"); // D moves 2 ahead
l.includes("E"); // E moves 2 ahead
l.includes("B"); // B moves 2 ahead
// Result: ["A", "B", "D", "E", "C"]
const l = new MoveToFrontSoList(["A", "B", "C", "D", "E"]);
l.includes("D"); // D -> front
l.includes("B"); // B -> front
l.includes("C"); // C -> front
// Result: ["C", "B", "D", "A", "E"]
const l = new TransposeSoList(["A", "B", "C", "D", "E"]);
l.includes("D"); // D swaps with C
l.includes("E"); // E swaps with C
l.includes("B"); // B swaps with A
// Result: ["B", "A", "D", "E", "C"]

How It Works

A self-organizing list (or SoList) reorders elements based on access patterns to improve search efficiency. Frequently accessed items move toward the head, achieving near constant-time access in the best case.

Supported heuristics:

  • Frequency Count - Accessed elements ordered by access count
  • k-in-a-Row - Accessed element moves to front after k consecutive accesses
  • Move-Ahead-k - Accessed element moves k positions toward the head
  • Move to Front - Accessed element moves directly to the head
  • Transpose - Accessed element swaps with its predecessor

Access Only Mode

By default (accessOnly: true), the list only rearranges on search operations. To also rearrange when adding elements, set accessOnly: false:

const l = new MoveToFrontSoList([1, 2, 3], { accessOnly: false });

Methods that trigger rearrangement:

  • Always: at(), find(), findIndex(), findLast(), findLastIndex(), includes(), indexOf(), lastIndexOf()
  • When accessOnly: false: push(), unshift(), insert()

API

Properties:

| Name | Description | | :------- | :----------------------------- | | length | Number of elements in the list |

Methods:

| Name | Description | | :-------------------- | :------------------------------------------------------------ | | [Symbol.iterator]() | Returns an iterator that yields each value | | at() | Returns the value at a given index | | concat() | Returns a new SoList merged with given iterables | | copyWithin() | Shallow copies part of list to another location | | entries() | Returns an iterator of key/value pairs | | every() | Checks if every element satisfies a predicate | | fill() | Changes all elements to a static value | | filter() | Creates a new SoList with elements satisfying a predicate | | find() | Returns the first element satisfying a predicate | | findIndex() | Returns the index of the first element satisfying a predicate | | findLast() | Returns the last element satisfying a predicate | | findLastIndex() | Returns the index of the last element satisfying a predicate | | flat() | Creates a new SoList with sub-lists flattened | | flatMap() | Maps then flattens the result by one level | | forEach() | Executes a function for each element | | includes() | Determines whether a value exists in the list | | indexOf() | Returns the first index of a given element | | insert() | Adds an element at a specific index | | isEmpty() | Checks if the list contains no elements | | isEqual() | Checks if the list equals a given iterable | | join() | Joins all elements into a string | | keys() | Returns an iterator of keys | | lastIndexOf() | Returns the last index of a given element | | map() | Creates a new SoList with mapped values | | pop() | Removes and returns the last element | | push() | Adds elements to the end | | reduce() | Reduces values to a single value (left-to-right) | | reduceRight() | Reduces values to a single value (right-to-left) | | remove() | Removes the element at a specific index | | reverse() | Reverses the order of elements | | shift() | Removes and returns the first element | | slice() | Returns a shallow copy of a portion | | some() | Checks if any element satisfies a predicate | | sort() | Sorts the elements | | splice() | Adds/removes elements | | toLocaleString() | Returns a localized string representation | | toReversed() | Returns a reversed copy | | toSorted() | Returns a sorted copy | | toSpliced() | Returns a spliced copy | | toString() | Returns a string representation | | unshift() | Adds elements to the beginning | | values() | Returns an iterator of values | | with() | Returns copy with element at index replaced |

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change. For contribution guidelines, see CONTRIBUTING.md.

License

The library is freely distributable under the terms of the MIT license.