View on GitHub

Listish

Queue, Stack, LinkedList implemented using Maps

Download this project as a .zip file Download this project as a tar.gz file

Listish

Basic list structures for JavaScript implemented using Maps as the underlying data storage.

Lists are superior to arrays for data where items need to be removed, inserted, concatenated, or split. They are inferior to arrays for indexed lookup and require more memory per item. They are equivalent for iteration.

Install

npm install listish

Or include in browser. Map and WeakMap are required (shim for IE9+ here).

Common properties and functions

All of the below data structures share the following:

LinkedList

Stack

FILO (first in, last out) data structure.

push          pop
\__\         /__/
   --> top --^   _
      |___|       |
      |___|     length
      |___|      _|

Queue

FIFO (First in, first out) data structure.

dequeue
 \___\    front
      ^--|____|____|____|
                         ^-- \___\
                            enqueue
         |-----length----|