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

my-data-structures

v0.0.7

Published

My implementation of custom data structures. Linked lists

Downloads

20

Readme

Data Structures Module

Overview

A various collection of data structures, including linked lists, stacks, queues, sets, and more, for Node.js and JavaScript projects. Simplify complex data operations and promote code reusability in web servers, utilities, and data-intensive apps with seamless CommonJS and ESM integration.

Key Data Structures

  • Linked List: A flexible linked list implementation for dynamic data storage and manipulation.
  • Stack: A stack data structure for managing data in a Last-In, First-Out (LIFO) manner.
  • Queue: A queue data structure for managing data in a First-In, First-Out (FIFO) manner.
  • Sets: A set data structure for handling unique values and set operations.

Benefits

  • Efficient Data Management: Easily handle and organize data with optimized data structures.
  • Code Reusability: Encapsulate common data operations, reducing code duplication.
  • Interoperability: Import and use the toolbox seamlessly in CommonJS and ESM environments.

Use Cases

  • Use linked lists for managing data with dynamic insertions and deletions.
  • Employ stacks and queues for algorithmic operations or task scheduling.
  • Utilize sets for maintaining unique collections of data.

Getting Started

  1. Install npm package to your project

    npm i my-data-structures

  2. Usage

  • ESM
    import { linkedList } from 'my-data-structures';

    const list = new LinkedList();
  • CommonJS
    const { linkedList } = require('my-data-structures');

    const list = new LinkedList();

Consult the documentation for details.

Documentation

Stack

Representing a stack data structure.

| property/method | params | return | description | | -------- | -------- | -------- | -------- | | .push(element) | element: any | undefined | add an element to the end of the stack | | .pop() | | element: any / null | remove the last element | | .peek() | | element: any / null | get the last element | | .isEmpty() | | boolean | check is the stack empty or not | | .size() | | number | get the stack size (length) | | .clear() | | undefined | remove all stack items |

Queue

The simple queue data structure.

| property/method | params | return | description | | -------- | -------- | -------- | -------- | | .enqueue(element) | element: any | undefined | add an element to the queue | | .dequeue() | | element: any / null | remove the element from the queue | | .front() | | element: any / null | get the first queue element | | .isEmpty() | | boolean | check is the queue emptynot | | .size() | | number | get the queue length | | .clear() | | undefined | remove all queue items |

Linked List

Linked list data structure.

| property/method | params | return | description | | -------- | -------- | -------- | -------- | | .append(data) | data: any | undefined | add an element to the end of the linked list | | .insert(position, data) | position: number, data: any | boolean | insert an element to the specified position in the linked list | | .remove(data) | data: any | data: any / null | remove an element from the list | | .removeAt(position) | position: number | data: any / null | remove an element by the position | | .indexOf(data) | data: any | index: number | to find the element index | | .toArray() | | array | to convert linked list to an array |

Doubly Linked List

Doubly Linked list data structure.

| property/method | params | return | description | | -------- | -------- | -------- | -------- | | .insert(position, data) | position: number, data: any | boolean | insert an element to the specified position | | .remove(data) | data: any | data: any / null | remove an element from the list | | .removeAt(position) | position: number | data: any / null | remove an element by the position | | .indexOf(data) | data: any | index: number | to find the element index | | .toArray() | | array | to convert doubly linked list to an array |

Extended set

Custom set data structure with extra methods.

| property/method | params | return | description | | -------- | -------- | -------- | -------- | | .union(otherSet) | otherSet: any | Set: any | Given two sets, this returns a new set with elements from both the given sets | | .intersection(otherSet) | otherSet: any | Set: any | Given two sets, this returns a new set with the elements that exist in both sets | | .difference(otherSet) | otherSet: any | Set: any | Given two sets, this returns a new set with all the elements that exist in the first set and do not exist in the second set | | .subset(otherSet) | otherSet: any | boolean | This confirms whether a given set is a subset of another set |