Skip to content

Latest commit

 

History

History

dcons

dcons

npm version npm downloads Twitter Follow

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

About

Double-linked list with comprehensive set of operations.

  • 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 (configurable, support custom PRNG)
  • Sorting (Merge sort, w/ custom comparator)
  • Slicing (sublist copies)
  • Splicing (delete and/or insert)
  • release() (emptying, GC friendly)
  • concat() / into()
  • map() / filter() / reduce()
  • compare() / equiv()
  • toJSON() transform (-> array)

Status

STABLE - used in production

Installation

yarn add @thi.ng/dcons

Package sizes (gzipped, pre-treeshake): ESM: 1.98 KB / CJS: 2.06 KB / UMD: 2.15 KB

Dependencies

API

Generated API docs

Head centric

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

Tail centric

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

Random Access

  • .length
  • nth()
  • nthCell()
  • setNth()

Insertion

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

Finding

  • find()
  • findWith()

Structure

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

TODO

Authors

Karsten Schmidt

License

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