Ready to take your JavaScript development to the next level? Meet npm Enterprise - the ultimate in enterprise JavaScript. Learn more »

@thi.ng/dcons

2.0.11 • Public • Published

@thi.ng/dcons

npm version npm downloads Twitter Follow

This project is part of the @thi.ng/umbrella monorepo.

About

Comprehensive doubly linked list structure with:

  • ES6 iterator support
  • Stack & queue API (front and/or back)
  • Random node access (read / write, O(n/2))
  • Node insertion (also w/ custom comparator)
  • Node finding (O(n))
  • Node swaps (O(1))
  • Reversing (O(n/2))
  • Rotation (left / right) (O(1))
  • Shuffling
  • Slicing (sublist copies)
  • Splicing (delete and/or insert)
  • release() (emptying, GC friendly)
  • concat() / into()
  • map() / filter() / reduce()
  • compare() / equiv()
  • toJSON() transform (-> array)

Installation

yarn add @thi.ng/dcons

Dependencies

Usage

// ES5
DCons = require("@thi.ng/dcons").DCons;
 
// ES6 / TS
import { DCons } from "@thi.ng/dcons";

API

list = new DCons([1, 2, 3]);
list.length
[...list]

Head centric

  • cons()
  • first()
  • drop()
  • setHead()

Tail centric

  • into()
  • push()
  • peek()
  • pop()
  • setTail()

Random Access

  • .length
  • nth()
  • setNth()

Insertion

  • insertBefore()
  • insertAfter()
  • insertBeforeNth()
  • insertAfterNth()
  • insertSorted()

Finding

  • find()
  • findWith()

Structure

  • copy()
  • concat()
  • slice()
  • splice()
  • swap()
  • shuffle()
  • reverse()
  • rotateLeft()
  • rotateRight()
  • release()

TODO...

Authors

  • Karsten Schmidt

License

© 2017-2018 Karsten Schmidt // Apache Software License 2.0

install

npm i @thi.ng/dcons

Downloadsweekly downloads

1,172

version

2.0.11

license

Apache-2.0

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability