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 🙏

© 2024 – Pkg Stats / Ryan Hefner

typescript-algos

v1.0.45

Published

Small collection of both common and uncommon data structures written in typescript and published for convenience and use in my projects. Most of the data structures are based off of implementations from [Introduction to Algorithms](https://en.wikipedia.or

Downloads

78

Readme

Typescript-algos

Small collection of both common and uncommon data structures written in typescript and published for convenience and use in my projects. Most of the data structures are based off of implementations from Introduction to Algorithms and were written for clarity rather than efficiency. The Aho Corasick implementation is based off of Stanford's CS166: Data Structures slides. The completion trie is a modified implementation of the Completion Trie presented in the paper Space-efficient data structures for Top-k completion (2013).

Feel free to use these for your own projects but unless you're using one of the starred algorithms I recommend using the implementations from mnemonist. If you are using one of the starred algorithms I'd love to know what you're building!

I've starred (⭐️) the algorithms which I find interesting.

  • AhoCorasick ⭐️
    • Implementation of Aho-Corasick algorithm an amazing algorithm for string matching when you have a large static number of patterns to match in a small to medium and dynamic text.
    • Given a set of N pattern strings and an input text of length m we can find all z instances of the pattern strings in the text in time O(m+z). Note that the number of pattern strings has no impact on the run time!
  • BinarySearchTree
  • CompletionTrie ⭐️
    • Very efficient top-K completions from a trie
    • Given an alphabet of size E, a prefix p, a number of requested completions k, and L where L is the average length of the completions excluding the common prefix p, returns the top k completions in time O(Ep + kL log(kL)). If we replace these numbers with some common values, say E=26, k=10, L=9, and p=1 we can find top-k completions in approx. 430 steps. Note that the number of prefix matches does not factor into the Big O time. The brute force topk would involve finding all matching entries (p + M*L) where p is the prefix, L is the average length of completions excluding the common prefix p and M is the number of matches plus M log(M) to sort the matches. For even a small number of matches say M=1000, p=1, L=9 this is approximately 16000 steps.
    • has rudimentary collision support where multiple values can be added with the same key. The collision support does not retain the same algorithmic guarantees outlined above.
  • CompressedTrie ⭐️
    • An implementation of a Trie where edges can contain more than one symbol at a time. Can greatly reduce the size of the trie under certain circumstances
  • Heap
  • LinkedList
  • Queue
  • Stack
  • Trie

Some of these data structures have methods for supporting serialization. If you want to try to serialize these data structures yourself and are running into circular reference issues, consider using flatted. I've had moderate success with flatted and ran into Maximum callstack size exceeded errors but those issues may be resolved.

Installation

npm install typescript-algos

Usage

import { LinkedList } from "typescript-algos";

const linkedList = new LinkedList([...Array(10).keys()]);

Releases

Commit your changes.
Run npm version patch && npm publish
Git Push