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

@anorcle/dsa

v1.0.0

Published

Implementation of Complex Data Structures and Algorithms for Web

Downloads

37

Readme

Data Structures and Algorithms For Web

Data Structures and Algorithms are highly useful for development of complex features in any Application. Here in this project we are targeting to implement most of the important and useful Data Structures and Algorithms for web Developers.

issues License Tweet Website GitHub

List of Implemented Data Structures

Installation

npm i @anorcle/dsa

Import

ECMAScript Modules

Import Everything

import * as dsa from '@anorcle/dsa';

Import Only Required Modules

import { AVL, BST, Deque, LinkedList, PriorityQueue, Queue, Set, Stack } from '@anorcle/dsa';

CommonJS

Import Everything

const dsa = require('@anorcle/dsa')

Import Only Required Modules

const { AVL, BST, Deque, LinkedList, PriorityQueue, Queue, Set, Stack } = require('@anorcle/dsa')

Examples

Max Heap

A Max Heap is a complete binary tree in which the value in each internal node is greater than or equal to the values in the children of that node.

import { PriorityQueue } from "@anorcle/dsa";

// compare function for Max Heap
const compare = (a: number, b: number): -1 | 0 | 1 => {
    if (a < b)
        return -1;
    if (a > b)
        return +1;
    return 0;
};

// create new Priority Queue of Numbers
const pq = new PriorityQueue<number>(compare);

pq.push(3);
pq.push(1);
pq.push(100);

console.log(pq.front) // 100

// remove the top element from priority queue and return it
pq.pop()
import { PriorityQueue } from "@anorcle/dsa";

// compare function for Max Heap
const compare = (a, b) => {
    if (a < b)
        return -1;
    if (a > b)
        return +1;
    return 0;
};

// create new Priority Queue of Numbers
const pq = new PriorityQueue(compare);
pq.push(3);
pq.push(1);
pq.push(100);
console.log(pq.front); // 100

// remove the top element from priority queue and return it
pq.pop();

Min Heap

A Min Heap is a complete binary tree in which the value in each internal node is smaller than or equal to the values in the children of that node.

import { PriorityQueue } from "@anorcle/dsa";

// compare function for Min Heap
const compare = (a: number, b: number): -1 | 0 | 1 => {
    if (a < b)
        return +1;
    if (a > b)
        return -1;
    return 0;
};

// create new Priority Queue of Numbers
const pq = new PriorityQueue<number>(compare);

pq.push(3);
pq.push(1);
pq.push(100);

console.log(pq.front) // 1

// remove the top element from priority queue and return it
pq.pop()
import { PriorityQueue } from "@anorcle/dsa";

// compare function for Min Heap
const compare = (a, b) => {
    if (a < b)
        return +1;
    if (a > b)
        return -1;
    return 0;
};

// create new Priority Queue of Numbers
const pq = new PriorityQueue(compare);
pq.push(3);
pq.push(1);
pq.push(100);
console.log(pq.front); // 1

// remove the top element from priority queue and return it
pq.pop();

Stack

Stack is a linear data structure which follows a particular order in which the operations are performed. The order may be LIFO(Last In First Out) or FILO(First In Last Out).

import { Stack } from "@anorcle/dsa";

const stack = new Stack<number>();
stack.push(3);
stack.push(1);
stack.push(100);

console.log(stack.top) // 100

// Remove Top Element from stack
stack.pop()

console.log(stack.top) // 1

Queue

A Queue is a linear structure which follows a particular order in which the operations are performed. The order is First In First Out (FIFO)

import { Queue } from "@anorcle/dsa";

const queue = new Queue<number>();
queue.push(3);
queue.push(1);
queue.push(100);

console.log(queue.front) // 3

// Remove First Element from Queue
queue.pop()

console.log(queue.front) // 1