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

@mkhstar/datastructures

v1.0.1

Published

Data Structures for Javascript

Downloads

4

Readme

@mkhstar/datastructures

Popular data structures implemented in Typescript (Javascript)

NPM JavaScript Style Guide

Install

npm

$ npm install --save @mkhstar/datastructures

Linked List

Constructors

constructor

+ new LinkedList<E>(...initialItems: E[]): LinkedList<E>

description: Constructs a new linked list

Methods

[Symbol.iterator]

[Symbol.iterator](): Generator<E, void, unknown>

Returns: Generator<E, void, unknown>


add

add(...items: E[]): void

description appends the elements at the tail (end) of the linked list

Parameters:

Name | Type | Description | ------ | ------ | ------ | ...items | E[] | |

Returns: void


addFirst

addFirst(item: E): void

description Adds an element to the linked list at the head

Parameters:

Name | Type | Description | ------ | ------ | ------ | item | E | |

Returns: void


addLast

addLast(item: E): void

description Adds an element to the tail of the linked list

Parameters:

Name | Type | Description | ------ | ------ | ------ | item | E | |

Returns: void


clear

clear(): void

description Clears the linked list

Returns: void


getFirstElement

getFirstElement(): null | E

Returns: null | E

The first element of the linked list


getLastElement

getLastElement(): null | E

Returns: null | E

The last element of the linked list


indexOf

indexOf(index: number): null | E

Parameters:

Name | Type | Description | ------ | ------ | ------ | index | number | The index to look up |

Returns: null | E


insertAt

insertAt(index: number, element: E): boolean

description inserts an element at the specified index

Parameters:

Name | Type | Description | ------ | ------ | ------ | index | number | | element | E | |

Returns: boolean


removeAt

removeAt(index: number): boolean

description Removes an element at the specified index, returns true if an element was removed and false otherwise

Parameters:

Name | Type | ------ | ------ | index | number |

Returns: boolean

boolean


removeElement

removeElement(element: E): boolean

description Removes an element that is equal to the element specified

Parameters:

Name | Type | Description | ------ | ------ | ------ | element | E | |

Returns: boolean


removeElementWhere

removeElementWhere(test: TestLinkedListElement<E>): boolean

description Remove an element that satisfy the test function

Parameters:

Name | Type | Description | ------ | ------ | ------ | test | TestLinkedListElement<E> | |

Returns: boolean


removeElements

removeElements(element: E): void

description Removes all elements that are equal to the element specified

Parameters:

Name | Type | Description | ------ | ------ | ------ | element | E | The element to look up |

Returns: void


removeElementsWhere

removeElementsWhere(test: TestLinkedListElement<E>): void

description Removes all elements that satisfy the test function

Parameters:

Name | Type | Description | ------ | ------ | ------ | test | TestLinkedListElement<E> | |

Returns: void


size

size(): number

Returns: number

The size of the linked list

Stack

Constructors

constructor

+ new Stack<E>(capacity?: number): Stack<E>

Methods

isEmpty

isEmpty(): boolean

description Is the stack empty?

Returns: boolean


peek

peek(): null | E

description Returns the element at the top of the stack

Returns: null | E


pop

pop(): null | E

description Removes an element from the top of the stack and return it

Returns: null | E


push

push(element: E): void

description Push an element to the stack

Parameters:

Name | Type | Description | ------ | ------ | ------ | element | E | |

Returns: void

Queue

Constructors

constructor

+ new Queue<E>(capacity?: number): Queue<E>

description Default capacity is 50. If you try to add more than the capacity of the queue, an error will be thrown

Getters

isEmpty

isEmpty(): boolean

description Is the Queue empty

Returns: boolean


isFull

isFull(): boolean

description Is the Queue full

Returns: boolean

Methods

dequeue

dequeue(): null | E

description Remove an element from the queue and return it

Returns: null | E


enqueue

enqueue(element: E): void

description Add an element to the queue

Parameters:

Name | Type | Description | ------ | ------ | ------ | element | E | |

Returns: void


peek

peek(): null | E

description Returns the element at the head of the queue

Returns: null | E

Tests

Tests will be written soon. But pull requests will be appreciated