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

@zeitfall/lists

v1.0.2

Published

Implementation of basic linked-list data structures

Readme

Overview

A minimal, zero-dependency TypeScript library implementing high-performance linear data structures: Singly (ForwardList) and Doubly (LinkedList) Linked Lists. Engineered for strict type safety, predictable memory management via aggressive reference nullification, and standardized APIs.

Requirements: Node.js >= 22.19.0 Installation: npm install @zeitfall/lists


Mathematical & Algorithmic Properties

| Operation / Metric | ForwardList | LinkedList | | --- | --- | --- | | Access (Head / Tail) | O(1) | O(1) | | Access (Index i) | O(n) | O(n) | | Search (Value) | O(n) | O(n) | | Insertion (Head / Tail) | O(1) | O(1) | | Insertion (Index i) | O(n) | O(n) | | Removal (Head) | O(1) | O(1) | | Removal (Tail) | O(n) | O(1) | | Removal (Index i) | O(n) | O(n) | | Space Complexity | O(n) | O(n) |

Note: n represents the total number of elements currently in the list.


API Reference

List<V unknown>

The primary shared interface defining the standardized API bounds for all list implementations.

  • Properties first: V | undefined, last: V | undefined, size: number
  • at(index: number): V | undefined Retrieves the value at the specified zero-based index.
  • contains(value: V): boolean Evaluates whether the specified value exists within the list via linear search.
  • prepend(value: V): this Inserts a new value before the current head of the list.
  • append(value: V): this Inserts a new value after the current tail of the list.
  • insertAt(index: number, value: V): boolean Inserts a value at a specific structural index.
  • removeFirst(): V | undefined Removes and returns the value at the head of the list.
  • removeLast(): V | undefined Removes and returns the value at the tail of the list.
  • removeAt(index: number): V | undefined Removes and returns the value at the specified index.
  • clear(): void Drops all internal node references, resetting the structural state to empty.
  • toArray(): V[] Generates a static Array<V> snapshot of the current list sequence.
  • [Symbol.iterator]() Yields list values sequentially from head to tail.

ForwardList<V unknown>

The primary structural class representing a singly linked list where each node maintains a single pointer to the subsequent node.

  • Constructor constructor() Initializes an empty linear forward-list instance.
  • Mechanism: Tail-targeted removal (#removeLast()) requires an O(n) forward traversal from the head, as internal nodes lack backward references to preceding structural elements.

LinkedList<V unknown>

The primary structural class representing a doubly linked list where each node maintains pointers to both preceding and subsequent nodes.

  • Constructor constructor() Initializes an empty bidirectional list instance.
  • Mechanism: Tail-targeted operations resolve in O(1) time due to the explicit maintenance of #tail and internal node #previous references.

Operational Context (Behavioral Notes)

  • Garbage Collection Optimization: Every structural removal routine (removeFirst, removeLast, removeAt, clear) explicitly nullifies the detached node's pointer references (next and/or previous). This invalidates previously reachable chains at the earliest possible execution phase, permitting the JS Garbage Collector to reclaim detached nodes without awaiting a full heap scan.
  • Bidirectional Traversal Logic: Index-based operations within LinkedList (such as .at(), .insertAt(), and .removeAt()) employ a targeted traversal algorithm. The internal #getNodeAt(i) routine evaluates whether i < size / 2. Indices in the lower half are walked forward from the head; indices in the upper half are walked backward from the tail. This halves the worst-case traversal constant.
  • Iterable Protocol: Both list structures natively implement Symbol.iterator, enabling sequential enumeration via standard for...of loops and array spread mechanics.

Usage Example

import { ForwardList, LinkedList } from '@zeitfall/lists';

// --- ForwardList Example ---
const forwardList = new ForwardList<number>();

forwardList.append(1).append(2).append(3);
forwardList.prepend(0);
forwardList.insertAt(1, 99); 

const droppedValue = forwardList.removeLast(); // 3

// --- LinkedList Example ---
const linkedList = new LinkedList<string>();

linkedList.append('a').append('b').append('c');
linkedList.prepend('z');

// Evaluated via bidirectional traversal (backward from tail)
const targetValue = linkedList.at(2); // 'b'

// Sequential evaluation
for (const value of linkedList) {
  console.log(value); // 'z', 'a', 'b', 'c'
}

const snapshot = linkedList.toArray(); // ['z', 'a', 'b', 'c']

// Structural wipe and reference nullification
linkedList.clear();