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

stl-kit

v5.4.3

Published

A modern JavaScript & TypeScript standard template library (STL) for data structures and algorithms. Includes high-performance implementations of Stack, Queue, Deque, Linked List, Vector, Set, Map, Tree, Heap, and Graph — inspired by C++ STL. Designed for

Downloads

22

Readme

A TypeScript-First Standard Template Library (STL) for Data Structures & Algorithms

A modern, high-performance JavaScript & TypeScript standard template library (STL) for classic and advanced data structures and algorithms. This library provides robust, type-safe, and reusable implementations of Stack, Queue, Deque, Linked List, Vector, Set, Map, Tree, Heap, Priority Queue, and Graph—designed for both beginners and professionals.

Use STL Kit to solve algorithmic problems, build efficient applications, or teach data structures in TypeScript or JavaScript. All data structures are optimized for performance and usability, with clean APIs and full documentation. Works seamlessly in Node.js, browser, and modern JavaScript/TypeScript projects.

Whether you need a fast priority queue for scheduling, a heap for sorting, or a linked list for flexible data manipulation, STL Kit has you covered. Explore the docs for detailed guides and examples.


Table of Contents


Installation

# Using npm
npm install stl-kit
# Using yarn
yarn add stl-kit
# Using pnpm
pnpm add stl-kit

Data Structures Overview & Quick Examples

This section gives a short, practical introduction to the most used data structures in STL Kit so you can get started quickly. Each entry shows the purpose, the most commonly used methods from this implementation, a small example you can copy, and a link to the full documentation in docs/ for complete details and advanced usage.

Important: examples show the library's actual method names (they match the implementation in src/structures). For deeper explanations and edge cases, follow the detailed guides linked below.

LinkedList

Doubly-linked list useful when you need efficient insertion/removal at both ends and constant-time splicing operations.

Common methods (from this implementation):

  • pushFront(value), pushBack(value) — add at head or tail
  • popFront(), popBack() — remove from head or tail
  • insertAt(value, index), eraseAt(index) — insert or remove at index
  • isEmpty(), clear(), toArray() — utility helpers

Example:

import { LinkedList } from 'stl-kit'

const list = new LinkedList({ initValues: [1, 2, 3] })
list.pushFront(0) // [0, 1, 2, 3]
list.pushBack(4) // [0, 1, 2, 3, 4]
console.log(list.popFront()) // 0
console.log(list.popBack()) // 4
console.log(list.toArray()) // [1, 2, 3]

Full guide: docs/linked-list.md

Deque

Double-ended queue implemented with a linked list. Use when you need a queue that can push/pop at both ends efficiently.

Common methods:

  • pushFront(value), pushBack(value)
  • popFront(), popBack()
  • front, back getters/setters, isEmpty(), toArray()

Example:

import { Deque } from 'stl-kit'

const dq = new Deque()
dq.pushBack(1)
dq.pushFront(0)
console.log(dq.front) // 0
console.log(dq.popBack()) // 1

Full guide: docs/deque.md

Queue

FIFO queue using a linked list under the hood — ideal for breadth-first algorithms and simple task scheduling.

Common methods:

  • push(value), pop(), peek()
  • isEmpty(), clear(), toArray()

Example:

import { Queue } from 'stl-kit'

const q = new Queue()
q.push('a')
q.push('b')
console.log(q.peek()) // 'a'
console.log(q.pop()) // 'a'

Full guide: docs/queue.md

Stack

LIFO stack implemented with a linked list. Use for depth-first search, function call simulation, or any LIFO ordering.

Common methods:

  • push(value), pop()
  • top getter/setter, peek() (alias), isEmpty(), toArray()

Example:

import { Stack } from 'stl-kit'

const s = new Stack()
s.push(1)
s.push(2)
console.log(s.top) // 2
console.log(s.pop()) // 2

Full guide: docs/stack.md

Vector

Resizable array (extends JavaScript Array) with STL-style helpers. Use when you want array semantics plus convenience methods found in classical STL vectors.

Common methods:

  • pushBack(val), popBack(), pushFront(val), popFront()
  • insertAt(index, val), eraseAt(index), resize(n)
  • front, back, isEmpty()

Example:

import { Vector } from 'stl-kit'

const v = new Vector({ initValues: [1, 2, 3] })
v.pushBack(4)
v.insertAt(1, 9)
console.log(v.toString()) // ['1', '9', '2', '3', '4'] (Array methods work)

Full guide: docs/vector.md

PriorityQueue

A high-performance priority queue backed by a binary heap (array-based). By default it behaves as a numeric max-heap, but you can provide a custom compareFn to change ordering (min-heap, object priorities, etc.).

Common methods:

  • push(node), pop() — insert and extract highest-priority element
  • peek() — inspect highest-priority element without removing
  • replace(node) — replace root and restore heap (more efficient than pop() + push())
  • emplace(...args) — construct in-place using provided factory
  • size() / length, toArray(), isEmpty()

Example (max-heap by default):

import { PriorityQueue } from 'stl-kit'

const pq = new PriorityQueue()
pq.push(1)
pq.push(5)
pq.push(3)
console.log(pq.peek()) // 5
console.log(pq.pop()) // 5

Example (min-heap via custom comparator):

const minPQ = new PriorityQueue({ compareFn: (a, b) => b - a })
minPQ.push(5)
minPQ.push(1)
console.log(minPQ.pop()) // 1

Full guide: docs/priority-queue.md


If you'd like a deeper tutorial or additional examples (TypeScript generics, factories for emplace, working with objects, or performance tips), check the linked docs under docs/ or open an issue/PR so we can improve the material.

Contributing

Contributions, issues, and feature requests are welcome! See CONTRIBUTING.md for guidelines.


License

MIT


Coming Soon

  • More algorithms and utilities!

Note: This library is under active development. API may change as new features are added.