Socket
Socket
Sign inDemoInstall

@perugi/linked-list

Package Overview
Dependencies
0
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @perugi/linked-list

A practice implementation of a Linked List in JavaScript.


Version published
Weekly downloads
3
decreased by-72.73%
Maintainers
1
Install size
11.0 kB
Created
Weekly downloads
 

Readme

Source

Linked List

A practice implementation of a Linked List in JavaScript as an ES6 Class, based on the specifications at: https://www.theodinproject.com/lessons/javascript-linked-lists.

Usage

const list = new LinkedList();
list.append(1);
list.append(2);
console.log(list.toString()); // ( 1 ) -> ( 2 ) -> null;

Methods

The following class methods are implemented:

  • append(value) adds a new node containing value to the end of the list.
  • prepend(value) adds a new node containing value to the start of the list.
  • size() returns the total number of nodes in the list.
  • head() returns the first node in the list.
  • tail() returns the last node in the list.
  • at(index) returns the node at the given index.
  • pop() removes the last element from the list.
  • contains(value) returns true if the passed in value is in the list and otherwise returns false.
  • find(value) returns the index of the node containing value, or null if not found.
  • toString() returns the LinkedList objects as strings. The format is: ( value ) -> ( value ) -> ( value ) -> null
  • insertAt(value, index) inserts a new node with the provided value at the given index.
  • removeAt(index) removes the node at the given index.
  • search(searchFunction) returns the first item which satisfies the passed searchFunction

FAQs

Last updated on 11 Feb 2024

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc