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

fley-linked-list

v0.0.3-pre

Published

Custom Implementation of linked arrays for JavaScript

Downloads

6

Readme

Simple implementation of linked arrays

This library has just 2 classes, it's "LinkedNode" and "LinkedArray".

To create linked array you must create instance of class LinkedArray like here:

// Option 1 : Insert multiple nodes in the list
const linkedArray = new LinkedArray<number>([12, 24, 48]); // [12, 24, 48];

// Option 2 : Insert single node in the list
const linkedArray = new LinkedArray<string>("Single Node"); // ["Single Node"];

// Option 3 : Insert multiple node without specifying a type
const linkedArray = new LinkedArray([true, -5, ["matrix"], "node"]);

// Option 4 : Insert new nodes with methods
const linkedArray = new LinkedArray();
linkedArray.push("Second");
linkedArray.shift("First");

Linked Arrays have some properties that you might use:

linkedArray.length // Gives the current length of an array.
linkedArray.start // Provides the starting node of the linked array.

Linked Arrays also support methods to work with:

// Get node by index. Throws an error if the length is exceeded
linkedArray.get(0); // Gives the first node. Equivalent of linkedArray.start.
linkedArray.get(-1); // Throws RangeError!
linkedArray.get(linkedArray.length - 1); // Gives you the last node of the linked array

// Insert node in the end of the linked list.
linkedArray.push("Node"); // Inserts Single node.
linkedArray.push(["Node", "Node #2", "Node #3"]); // You can insert multiple nodes.
linkedArray.push([[1, 2, 3]]); // If your linked array consists of regular arrays and you need to insert just a single array, try this.
linkedArray.shift("Node"); // Insert the node in the start

// Methods to remove nodes
linkedArray.remove(1); // Remove the node by id.
linkedArray.pop(); // Remove the last node. Uses linkedArray.remove() under the hood.
linkedArray.unshift(); // Remove the first node. Also uses linkedArray.remove() under the hood.

There's also ListNode class, it's a particular class for nodes inside linked array. They contain 2 fields of the current node (.node) and the next node (.nextNode). The next node is also instance of LinkedNode containing value and link to the next node.

linkedArray.get(0).node // Returns value of the node
linkedArray.get(0).nextNode // Returns instance of LinkedNode of the next node