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

@bletchley-tech/linkedlist

v1.0.0

Published

A JavaScript-native implementation of the Linked List data structure

Downloads

2

Readme

Linked List

Linked List provides a native implementation of a linked list data structure in JavaScript.

Installation

Using npm:

$ npm install @bletchley-tech/linkedlist

Usage

Linked List provides a native implementation of a linked list data structure in JavaScript designed for use in a Node.js environment. All operations are performed synchronously.

The package provides a single class, LinkedList, which is used to create and manage a singly linked list, like shown below:

  1. Import/Require the package:

    // CommonJS
    const LinkedList = require('@bletchley-tech/linkedlist');
    
    //ES6+
    import LinkedList from '@bletchley-tech/linkedlist';

    This will import the LinkedList class from the package and allow you to create new instances of the class.

  2. Create a new instance of the LinkedList class:

    const list = new LinkedList();

    This will create a new instance of the LinkedList class and store it in the list variable.

  3. Use the list:

    list.add('a'); // Create a node with value 'a' and add it to the end of the list
    list.addMany(['b', 'c', 'd']); // Create nodes for each element in the array and add each to the end of the list.
    list.list; // "a -> b -> c -> d"

LinkedList Class

The LinkedList has two properties, head and length. Head is the first node in the list and length is the number of nodes in the list.

The LinkedList class takes advantage of the new private class properties/methods JavaScript feature introduced in ES2022. This means that once the LinkedList is initialized, it will not be able to be changed except by the class' own methods.

Class Methods

add(value)

The add method adds a node with data 'value' to the end of the list.

list.add(value); // Add a node with data 'value' to the end of the list

addMany(values)

The addMany method adds nodes with data from 'values' to the end of the list. The values to be added can be passed as an array or separated by commas like multiple arguments.

list.addMany(1, 2, 3); // Add nodes with data 1, 2, 3 to the end of the list

// or

list.addMany([1, 2, 3]); // Add nodes with data 1, 2, 3 to the end of the list

remove(position)

The remove method will remove and return the node at the specified position from the list. The first node is at position 1.

const removed = list.remove(1); // Remove and return the node at position 1 (head) from the list

nodeAt(position)

The nodeAt method will return the node at the specified position from the list. The first node is at position 1.

const node = list.nodeAt(1); // Return the node at position 1 (head) from the list

valueAt(position)

The valueAt method will return the value of the node at the specified position from the list. The first node is at position 1.

const value = list.valueAt(1); // Return the value of the node at position 1 (head) from the list

Class Attributes

head

list.head; // Return the first node in the list

This will return the node at the head of the list.

length

list.length; // Return the number of nodes in the list

This will return the number of nodes in the list.

list

list.list; // Return the list as a string of each nodes' data separated by a ->

License

LinkedList is licensed under the MIT License (see the LICENSE file for mor information).