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

algorify

v1.0.0

Published

A data structures and algorithms library written in typescript

Downloads

75

Readme

Algorify

Algorify is a comprehensive TypeScript library that provides a collection of data structures and algorithms. It is designed to simplify the use of common structures like linked lists, trees, graphs, and more in TypeScript-based projects. Algorify is suitable for learning, development, and competitive programming scenarios.

Features

  • Data Structures: Includes commonly used data structures such as:

    • Linked Lists
    • Binary Search Trees
    • Disjoint Sets
    • Graphs (Adjacency Lists and Matrices)
    • LRU Cache, and more.
  • Algorithms: Includes a wide range of algorithms for:

    • Sorting
    • Searching
    • Graph traversal (BFS, DFS)
    • Union-Find and others.
  • Fully TypeScript Supported: Benefit from TypeScript's static typing, making code more reliable and maintainable.

Installation

You can install Algorify via npm:

npm install algorify

Usage

Import the relevant data structure or algorithm into your TypeScript file and use it as needed. For example, to use the SinglyLinkedList:

import { SinglyLinkedList } from 'algorify';

const list = new SinglyLinkedList<number>();
list.append(1);
list.prepend(2);
list.insertAt(3, 1);

console.log(list.get(1)); // Output: 3

Examples

1. Disjoint Set (Union-Find):

import { DisjointSet } from 'algorify';

const ds = new DisjointSet(5);
ds.makeSet(0);
ds.makeSet(1);
ds.union(0, 1);

console.log(ds.connected(0, 1)); // Output: true

2. Binary Search Tree:

import { BinarySearchTree } from 'algorify';

const bst = new BinarySearchTree<number>();
bst.insert(10);
bst.insert(5);
bst.insert(15);

console.log(bst.search(15)); // Output: true

API Reference

Data Structures

  • SinglyLinkedList

    • prepend(item: T): Adds an item to the start of the list.
    • append(item: T): Adds an item to the end of the list.
    • insertAt(item: T, idx: number): Inserts an item at the specified index.
    • removeAt(index: number): Removes an item at the specified index.
    • get(index: number): Retrieves the item at the given index.
  • DisjointSet

    • makeSet(i: number): Creates a set for element i.
    • union(i: number, j: number): Merges the sets containing i and j.
    • find(i: number): Finds the representative of the set containing i.
    • connected(i: number, j: number): Checks if i and j are in the same set.
  • BinarySearchTree

    • insert(value: T): Inserts a value into the binary search tree.
    • search(value: T): Checks if a value exists in the tree.
    • remove(value: T): Removes a value from the tree.

Algorithms

  • Sorting

    • Quick Sort, Merge Sort, Insertion Sort, etc.
  • Graph Algorithms

    • Breadth-First Search (BFS)
    • Depth-First Search (DFS)
    • Dijkstra's Algorithm, etc.

Testing

To run the tests:

npm test

Tests are written in Jest, and the test files are located in the __tests__ directory.

Build

To build the library:

npm run build

This will compile the TypeScript files to JavaScript in the dist directory.

License

This project is licensed under the ISC License.

Contribution

Contributions are welcome! Feel free to open issues or submit pull requests. Before submitting, ensure that your code follows the existing code style and all tests pass.

Author

Muhammad Awwab Khan


Happy coding with Algorify!