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 🙏

© 2025 – Pkg Stats / Ryan Hefner

algostructs

v1.0.1

Published

All of the data structures Javascript is missing + some basic algorithm implementations.

Downloads

9

Readme

Algostructs

A zero-dependency TypeScript implementation of essential data structures and algorithms missing from JavaScript.

Features

  • 🎯 Type-Safe: Full TypeScript support with generics
  • 🔄 Immutable: All operations return new instances
  • 🚀 Efficient: Optimized implementations of classic algorithms
  • 📦 Zero Dependencies: Pure TypeScript/JavaScript implementation
  • 🧪 Well-Tested: Comprehensive test coverage

Installation

npm install algostructs

Usage

Priority Queue & Heaps


import { MinHeap, MaxHeap, PriorityQueue } from 'algostructs';

// Create a min heap const minHeap = new MinHeap<number>(); const heap2 = minHeap.add(5).add(3).add(7);
console.log(heap2.peek()); // 3

// Custom priority queue interface Task { priority: number; name: string; }

const taskQueue = new PriorityQueue<Task>((a, b) => a.priority - b.priority); const queue2 = taskQueue.enqueue({
priority: 1, name: 'Important task' });

Linked Lists


import { LinkedList, DoublyLinkedList } from 'algostructs';

// Singly linked list const list = new LinkedList<number>(); const list2 = list.prepend(1).append(2).prepend(0);

// Doubly linked list with reverse iteration const dlist = new DoublyLinkedList<number>(); const dlist2 =
dlist.append(1).append(2).append(3); for (const item of dlist2.reverseIterator()) { console.log(item); // 3, 2, 1 }

Trees


import { BinarySearchTree, Trie } from 'algostructs';

// Binary Search Tree const bst = new BinarySearchTree<number>(); const bst2 = bst.insert(5).insert(3).insert(7);

// Trie for prefix searching const trie = new Trie(); const trie2 = trie .insert("hello") .insert("help")
.insert("world"); console.log(trie2.findWordsWithPrefix("hel")); // ["hello", "help"]

Searching


import { Searching } from 'algostructs';

const arr = [1, 2, 3, 4, 5];
const result = Searching.binarySearch(arr, 3);
console.log(result); // { element: 3, index: 2, comparisons: 2 }

// Smart search that picks the best algorithm
const smartResult = Searching.search(arr, 3);

Sorting


import { Sorting } from 'algostructs';

const arr = [3, 1, 4, 1, 5, 9];
const sorted = Sorting.quickSort(arr);
console.log(sorted); // [1, 1, 3, 4, 5, 9]

// Use optimal sorting based on array size
const smartSorted = Sorting.sort(arr);

Key Benefits

  1. Immutable Operations: All operations return new instances, making your code more 2. predictable and easier to reason about.
  2. Type Safety: Comprehensive TypeScript definitions help catch errors at compile time.
  3. Performance Optimized: Implementations follow best practices for performance.
  4. Memory Efficient: Careful memory management in all operations.

Documentation

Each data structure and algorithm includes:

Usage examples Type definitions Comprehensive JSDoc comments

Contributing

Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.

License MIT © [Joaquin Lopez]