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

ts-jadsl

v0.0.3

Published

Just another data structures library

Downloads

2

Readme

CircleCI Coverage Status

(WIP)

Data Structures:


ListNode:

A node of a singly-linked list.

Constructor:
ListNode<T>(value: T)
Properties
  • value: T Value held by node.
  • next: ListNode<T> | null Next pointer of node.
Parameters:
  • value: T (mandatory): value held by list node.

LinkedList:

A simple, singly-linked list.

Constructor:
LinkedList<T>(initArray?: T[])
Parameters:
  • initArray: T[] (optional): Array of elements with which linked list will be initialized, inserted in order
Methods:
  • length(): number Returns length of list.

  • insertAt(index: number, value: T): LinkedList<T> Inserts valueat index in the list, returns the list.

  • insertAtHead(value: T): LinkedList<T> Inserts value at head, returns the list.

  • insertAtTail(value: T): LinkedList<T> Inserts value at tail, returns the list.

  • get(index: number): T | null Returns element at index. Returns null if index is out of bounds for the list.

  • deleteAt(index: number): T | null Deletes element at index, returns the deleted element. Returns null if index is out of bounds and delete is not performed.

  • toArray(): T[] Returns an array of elements of the list, in order.

  • getHeadNode(): ListNode<T> | null Returns the head node of the list, returns null if list is empty. NOTE: Should be used ONLY if the user does not wish to use the list functions, and just wants a reference to the head node of the list.


Stack:

Constructor:
Stack<T>(initArray?: T[])
Parameters:
  • initArray: T[] (optional): Array of elements with which the stack will be initialized (insertion of each element performed in reverse order, i.e, first element of array will be top of stack)
Methods:
  • size(): number Returns size of the stack (number of elements).

  • peek(): T | null Returns top element of stack. Returns null if stack empty.

  • isEmpty(): boolean Returns true if stack empty, false if otherwise.

  • push(value: T): Stack<T> Pushes value on top of stack, returns the Stack instance.

  • pop(): T | null Pops and returns top value from stack. Returns null if stack empty.


Queue:

A simple, single-ended queue.

Constructor:
Queue<T>(initArray?: T[])
Parameters:
  • initArray: T[] (optional): Array of element from which the queue will be initialized (insertion of each element performed in order)
Methods:
  • enqueue(value: T): Queue<T> Adds value to rear of queue, returns the Queue instance.

  • dequeue(): T | null Removes and returns element at front of queue. Returns null if queue empty.

  • getFront(): T | null Returns value in front of the queue. Returns null if queue empty.

  • isEmpty(): boolean Returns true if queue empty, false if otherwise.

  • length(): number Returns length of queue.


Heap:

A binary heap with internally implemented with an array. Can also be considered implementation of a priority queue.

Constructor:
Heap<T>(comparatorFunction: (firstElement: T, secondElement: T) => number, initArray?: Array<T>)
Parameters:
  • comparatorFunction: (firstElement: T, secondElement: T) => number (mandatory): A comparator function to return a number. If number is greater than 0, bubble-up will be performed in the heapify operation.
  • initArray: Array<T> (optional): Array which will be heapified into initial heap.
Methods:
  • insert(value: T): Heap<T> Inserts value in the heap.

  • extract(): T | null Removes and returns value from root of heap (highest priority). Returns null if heap empty.

  • peek(): T | null Returns value at root of heap.

  • size(): number Returns size of heap (number of elements)


BinaryTreeNode:

Constructor
BinaryTreeNode<T>(value: T)
Parameters:
  • value (mandatory): Value for the binary tree node.
Properties:
  • value: T value of node
  • left: BinaryTreeNode<T> | null left of current node
  • right: BinaryTreeNode<T> | null right of current node
Methods:
  • isLeafNode(): boolean Returns true is node is leaf node, false if otherwise.

  • height(): number Returns height of the subtree with current node as root.

  • getInorderTraversal(): Array<T> Returns array of elements in subtree rooted at node in an inorder fasion.

  • getPreorderTraversal(): Array<T> Returns array of elements in subtree rooted at node in a preorder fasion.

  • getPostorderTraversal(): Array<T> Returns array of elements in subtree rooted at node in a postorder fasion.

  • invert(): BinaryTreeNode<T> | null Inverts subtree with node as root, returns the node.

  • isBalanced(): boolean Returns true if subtree rooted at node is height balanced, false if otherwise.

  • isBinarySearchTree(keyFunction: (value: T) => number) Returns true if subtree rooted at node is a valid binary search tree, needs a keyFunction to get numeric value from data stored in node (see BinarySearchTree)


BinaryTree:

Abstract class - therefore, no constructor definition.

Properties:
  • root: BinaryTreeNode<T> | null Root node of the binary tree.
Methods:
  • getInorderTraversal(): Array<T> Returns array of elements in tree in an inorder fasion from root of tree.

  • getPreorderTraversal(): Array<T> Returns array of elements in tree in a preorder fasion from root of tree.

  • getPostorderTraversal(): Array<T> Returns array of elements in tree in a postorder fasion from root of tree.

  • height(): number Returns height of the tree.

  • invert(): BinaryTree<T> Inverts the BinaryTree, returns the tree.

  • isBalanced(): boolean Returns true if binary tree is height balanced, false if otherwise.


BinarySearchTree:

Derived class: Derived from BinaryTree.

Constructor
BinarySearchTree<T>(keyFunction: (value: T) => number, initArray?: Array<T>)
Parameters
  • keyFunction: (value: T) => number (mandatory): Function that takes value of tree node as a parameter to get the key value, on the basis of which BST inserts/search will be performed

  • initArray: Array<T> (optional): Array with which tree is initialized by inserting elements of array in order.

Properties:
  • root: BinaryTreeNode<T> | null Root node of the binary tree
Methods:
  • insert(value: T): BinarySearchTree<T> Inserts new node with value in BST, returns BST instance.

  • delete(value: T): BinarySearchTree<T> Deletes node with value in BST, returns BST instance.

  • search(value: T): BinaryTreeNode<T> | null Returns tree node with value in BST, null if node not found.

  • getMin(): T | null Returns value in tree with min key, null if tree empty.

  • getMax(): T | null Returns value in tree with max key, null if tree empty.


AvlTree:

Derived class: Derived from BinarySearchTree.

Constructor
AvlTree<T>(keyFunction: (value: T) => number, initArray?: Array<T>)
Parameters
  • keyFunction: (value: T) => number (mandatory): Function that takes value of tree node as a parameter to get the key value, on the basis of which BST inserts/search will be performed

  • initArray: Array<T> (optional): Array with which tree is initialized by inserting elements of array in order.

Properties:
  • root: BinaryTreeNode<T> | null Root node of the binary tree - (NOTE: Access this property ONLY if you do not wish to use the methods of the class, and want to write your own functions)
Methods:
  • insert(value: T): AvlTree<T> Inserts new node with value in BST, returns AvlTree instance.

  • delete(value: T): AvlTree<T> Deletes node with value in BST, returns AvlTree instance.

  • search(value: T): BinaryTreeNode<T> | null Returns tree node with value in BST, null if node not found.

  • getMin(): T | null Returns value in tree with min key, null if tree empty.

  • getMax(): T | null Returns value in tree with max key, null if tree empty.