Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@akashbabu/node-dll

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@akashbabu/node-dll

DLL(doubly linked list) library for javascript projects

  • 1.1.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.2K
increased by108.19%
Maintainers
1
Weekly downloads
 
Created
Source

node-dll Coverage Status Build Status Maintainability

DLL(Doubly linked list) implementation for javascript projects

Introduction

Doubly linked list(DLL) is inevitable in certain situation where performance is preferred while slicing an array (maybe there are more to it, but this is mostly my PoV). So this library was created with a simple, yet powerful interface for interacting with the underlying DLL schema.

This library is written in typescript for robust APIs and type support.

Documentation

API method name has been carefully chosen to nearly match Array methods, such that learning curve is least and adaptability is higher. But a few methods could not have had a different name and we'd to convince ourselves with those method name.

API - DLL

import {DLL} from 'node-dll';
constructor():

This creates a new instance of DLL

Example:

const dll = new DLL();
.getHead()

Returns the first item in the list

Example:

const dll = new DLL()
dll.push('test')

dll.getHead() // => DLLItem<'test'>
.getTail()

Returns the last item in the list

Example:

const dll = new DLL()
dll.push('test1')
dll.push('test2')

dll.getTail() // => DLLItem<'test2'>
.shift()

Removes and returns the first item in the list

Example:

const dll = new DLL()
dll.push('test1')
dll.push('test2')

dll.shift() // => 'test1'

dll.length // => 1
.unshift()

Add the given item to the head of DLL chain

Example:

const dll = new DLL()
dll.push('test1')
dll.unshift('test0')

dll.getHead() // => DLLItem<'test1'>

dll.length // => 2
.forEach(cb)

Iterates through the entire DLL chain

Example:

const dll = new DLL()
dll.push('test1')
dll.push('test2')

dll.forEach((data, i) => {
  console.log(data, i)
})

// => test1 0
// => test2 1
.map(cb)

Iterates through the entire DLL chain and returns a resultant array

Example:

const dll = new DLL()
dll.push('test1')
dll.push('test2')

const results = dll.map((data, i) => {
  return `${i + 1}) ${data}`;
})

console.log(results) // => ['1) test1', '2) test2']
.push(data)

Adds the given items to the tail of DLL chain and returns the added item, such that the same can be used to remove the item from the list

Example:

const dll = new DLL()

const item = dll.push('test1')

dll.length // => 1
dll.getHead() // => DLLItem<'test1'>

dll.remove(item)

dll.length // => 0
.remove(dllItem)

Removes the given item from DLL chain and returns true if the removal was successful

Example:

const dll = new DLL()

const item = dll.push('test1')

dll.length // => 1
dll.getHead() // => DLLItem<'test1'>

dll.remove(item) // => true

dll.length // => 0

Contribution

All contributions are welcome!!!

But before raising any issue, please check the issue-tracker in github if there is any matching issues already in the pipeline, if not then please go ahead and raise your own.

PR Guidelines:

  • Make sure to include corresponding test cases
  • Be generous on code comments
  • Write documentation if necessary
  • Wait for your approval 😜

Licence

MIT

Keywords

FAQs

Package last updated on 01 Dec 2019

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