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

@fredvel/linked-list-js

v1.0.4

Published

Linked lists are a very useful linear data structures, similar to arrays

Downloads

8

Readme

Linked-list-js

linked lists are a data structure which will have various benefits.

  1. Linked lists are very efficient when inserting and deleting data. This is because there is no need to shift any elements over, as is the case with arrays.

  2. Linked lists can be easily extended and can be made into a circular linked list if needed.

  3. Linked lists use less memory than arrays because they only need to store the data and the link to the next element, as opposed to the whole array.

  4. Linked lists are very flexible and can be used to implement other data structures, such as stacks and queues.

installation

# With npm
npm i @fredvel/linked-list-js

# or yarn

yarn add @fredvel/linked-list-js

DISCLAIMER!!

This library only works on "modules" and not on "commonjs"

How to use Linked-list-js?

To use this library it is pretty easy!

import LinkedList from "@fredvel/linked-list-js";

const mylist = new LinkedList();

Methods

Add new element

const myList = new LinkedList();

myList.appendNewNode(value);

Get the length of the linked list

const myList = new LinkedList();

myList.size();

Get All nodes, this method returns an array with all nodes inside

const myList = new LinkedList();

myList.getAllNodes();

Remove the last element, like Array.pop();

const myList = new LinkedList();

myList.removeLastNode();

Get a node by index

const myList = new LinkedList();

myList.getByIndex(index);

To Clear all linked list an remove all nodes

const myList = new LinkedList();

myList.clear();

This method insert an element at the very first place in linked list, like Array.unshift()

const myList = new LinkedList();

myList.insertAtHead(value);

To get the first element in the linked list

const myList = new LinkedList();
myList.getFirst();

To get the last element in the linked list

const myList = new LinkedList();

myList.getLast();

Method to add an element by index

const myList = new LinkedList();

myList.insertAt(index, value);

Method to remove an element by index

const myList = new LinkedList();

myList.removeFrom(index);

Array Methods clone:

FindNode() method returns a simple value but with the first match of the callback.

const myList = new LinkedList();
myList.appendNewNode("value1");
myList.appendNewNode("value2");
myList.appendNewNode("value3");

const findLinkedList = myList.findNode((item) => item === "value2");
console.log(findLinkedList); // value2

MapNode() method returns another linked list.

const myList = new LinkedList();
myList.appendNewNode("value1");
myList.appendNewNode("value2");

const findLinkedList = myList.mapNode((item) => item + "test");
console.log(findLinkedList.getAllNodes()); // ["value1test", "value2test"]

filterNodes() method returns a linked list but with the matches of the callback

const myList = new LinkedList();
myList.appendNewNode(1);
myList.appendNewNode(2);
myList.appendNewNode(3);
myList.appendNewNode(4);
myList.appendNewNode(5);

const newLinkedListMapped = myList.filterNodes((num) => num > 2);
console.log(newLinkedListMapped.getAllNodes()); // [3,4,5]