New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

js-structures

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

js-structures

Set of data structures implemented in Javascript. Currently the following structures are implemented:

  • 1.0.5
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
8
increased by14.29%
Maintainers
1
Weekly downloads
 
Created
Source

JS Structures

Set of data structures implemented in Javascript. Currently the following structures are implemented:

LinkedList

This a a doubly linked list implementation. Each node of the list is always linked to the previus and successive node with the properties prev and next.

The node object stored in the list has the following schema

{
    "title": "List node",
    "type": "object",
    "properties": {
        "data": {
            "type": "any"
        },
        "prev": {
            "type": "object"
        },
        "next": {
            "type": "object"
        }
    }
}

Methods

  • add(data) - Append a node with arbitrary data to the end of the list list.
  • addFirst(data) - Insert a node with arbitrary data at the beginning of the list.
  • remove(index) - Remove the node at the given index without retrieving it. Throws RangeError if the list is empty or if the index is too small or too big.
  • removeFirst() - Removes the first node of the list, it's a shortcut for remove(0)
  • removeLast() - Removes the last node of the list, it's a shortcut for remove(List.size() - 1)
  • peek(index) - Retrieve the node at the given position
  • get(index) - Retrieve and remove the node at the given position
  • size() - Get the current size of the list

Queue

It's a collection that order elements with FIFO order. It's baked by the LinkedList so the elements contained in the queue are the same as the list but without access to the other elements.

Methods

  • enqueue(data) - Add data to the queue
  • dequeue() - Retrieve and remove the next element in the queue if any, otherwise return null
  • peek() - Retrieve just the next element from the queue, without removing it.
  • size() - Return the queue size.

Stack

It's a collection that order elements with LIFO order. It's baked by the LinkedList so the elements contained in the stack are the same as the list but without access to the other elements.

Methods

  • push(data) - Add data to the stack
  • pop() - Retrieve the next element of the stack if any, otherwise return null
  • size() - Return the stack size

Swag

NPM Status

NPM

Build

wercker status

Code climate

Code Climate Test Coverage

FAQs

Package last updated on 29 Oct 2015

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc