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

@tscafejr/common-data-structures

v1.1.4

Published

This is a library for common data structures that I use in various projects

Readme

Overview

This is a library to manage commonly used data structures in my projects.

Methods

Table of Contents

Common Data Structures

CircularLinkedList

Extends LinkedList

Creates a new CircularLinkedList instance

Properties

  • head Node? This is the head of the linked list.
  • tail Node? This is the tail of the linked list.
  • size number This is the length of the linked list.

add

This method adds an element to the end of the circular linked list.

Parameters

  • element any The element being added to the circular linked list.

Returns number The size of the linked list.

shiftHead

This method shifts the head of the circular linked list to to the right.

Graph

Creates a new Graph instance.

Properties

  • nodes (Array<any> | Array<string>) The list of nodes.
  • adjacencyList Object This tracks the adjacent nodes for a given node.

addNode

This method adds a node to the graph.

Parameters

  • node (string | any) The node that is inserted into the graph.

addEdge

This method only adds an edge to the graph if it does not exist already.

Parameters

  • node1 (string | any) The origin edge.
  • node2 (string | any) The destination edge.
  • weight number? The weight / cost of the link between the nodes.

findPathWithDijkstra

This finds a path from the start node to the end node using dijkstra's algorithm.

Parameters

  • startNode (string | any) The origin node.
  • endNode (string | any) The destination node.

Returns {path: [any], distance: number}

LinkedList

Creates a new LinkedList instance

Properties

  • head Node? This is the head of the linked list.
  • tail Node? This is the tail of the linked list.
  • size number This is the length of the linked list.

add

This method adds an element to a linked list and increments the size of the linked list.

Parameters

  • element any The element to add to the linked list.

addToBottom

This method adds an element to the end of the linked list.

Parameters

  • element any This is the element that will be added to the linked list.

addToTop

This method adds an element to the beginning of the linked list.

Parameters

  • element any This is the element that will be added to the linked list.

insertAt

This method adds an element at a specific index of a linked list

Parameters

  • element
  • index

Returns boolean

removeFrom

This method removes an element from a given index and returns that element

Parameters

  • index

Returns (number | any)

removeElement

This method removes a specific element from the linked list

Parameters

  • element

Returns (WebAssembly.TableKind | number)

indexOf

This method returns the index of given element

Parameters

  • element

Returns number

isEmpty

This method lets us know whether or not a linked list is empty.

Returns boolean

getTail

This method returns the tail node.

Returns Node The tail node.

getHead

This method returns the head node.

Returns Node The head node.

getSize

This method returns the size of the linked list.

Returns number The size of the linked list.

removeHead

This method removes a Node from the top of a linked list.

Returns any The node to return.

Node

Creates a new Node instance

Parameters

  • element any The element value of the node.

Properties

  • element any The element value of the node.
  • next Node? The next element following the node.
  • prev Node? The previous node.

PairTracker

This creates a new Pair Tracker instance

Parameters

  • collection Set<string> This set tracks the elements that have been added to the tracker

addPair

This method adds a pair to the pair tracker.

Parameters

orderPair

This method orders the pair and returns the same string.

Parameters

Returns string

pairExists

This method lets us know whether or not the pair is in the tracker.

Parameters

Returns boolean

getSize

This method returns the size of the pair tracker.

Returns number

PriorityQueue

Creates a new PriorityQueue instance

Properties

  • collection Array<any> The queue collection.
  • size number The number of elements in the queue.

enqueue

This method adds an element to the collection

Parameters

  • element

dequeue

This method removes an element from the collection

Returns any

isEmpty

This method checks to see if the collection is empty or not

Returns boolean

Queue

Creates a new Queue Instance

Properties

  • items Array<any> The items in the queue.
  • size number The size of the queue.

push

This method pushes an item onto the queue.

Parameters

  • item any

pop

This method removes the first item added to the queue.

Returns (null | any)

peek

This method returns the last item added to the queue without removing it.

Returns (null | any)

Stack

Creates a new Stack Instance

Properties

  • items Array<any> The items in the stack.

push

This method pushes an item onto the stack.

Parameters

  • item any

pop

This method removes the last item from the added to the stack.

Returns (null | any)

peek

This method returns the last item added to the stack without removing it.

Returns (null | any)

Trie

Creates a new Trie instance.

Properties

  • root Object The root node of the trie.

addWord

This method adds a word to the trie.

Parameters

  • word String The word to add to the trie.

addLetter

This method adds a letter to the trie on the node passed into the method.

Parameters

  • letter String The letter to add to the path.
  • node Object The node that the letter will be added to.

Returns Object

inTrie

This method lets us know whether a word is in the trie or not.

Parameters

  • word String The word being checked in the trie.

Returns boolean