# dequeue

> A simple double ended queue datastructure

Latest version **1.0.5** (published 2013-08-29) · 0 weekly downloads

## Install

```sh
npm install dequeue
pnpm add dequeue
yarn add dequeue
bun add dequeue
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.5 |
| Published | 2013-08-29 |
| First published | 2012-07-06 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Node | * |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 23 |
| Author | LLeo |
| Maintainers | lleo |
| Keywords | datastructure, queue, double ended queue, fifo, FIFO, linked list |

## Links

- npm: https://www.npmjs.com/package/dequeue
- Repository: https://github.com/lleo/node-dequeue
- Issues: https://github.com/lleo/node-dequeue/issues
- npm.io page: https://npm.io/package/dequeue

## Alternatives

- [cron](https://npm.io/package/cron.md) — 4.9M weekly downloads
- [@vercel/queue](https://npm.io/package/@vercel/queue.md) — 731.6K weekly downloads
- [create-sonicjs](https://npm.io/package/create-sonicjs.md) — 1.6K weekly downloads
- [@exellix/jobs-api](https://npm.io/package/@exellix/jobs-api.md) — 941 weekly downloads
- [@forwardimpact/libskill](https://npm.io/package/@forwardimpact/libskill.md) — 575 weekly downloads

## Recent versions

- 1.0.5 (latest) — 2013-08-29
- 1.0.4 — 2013-03-22
- 1.0.3 — 2012-07-08
- 1.0.2 — 2012-07-08
- 1.0.1 — 2012-07-07
- 1.0.0 — 2012-07-06

## README

A Simple Double Ended Queue Datastructure
=========================================

Dequeue is implemented as a doubly linked circular list with a titular head
node. By "titular head node", I mean an empty node to designate the beginning
and end of the circularly linked list. I first saw this construction in the
linux kernel source and it seem simple and elegant. I added the `.length`
property to use it like I was using an Array.

I was using a javascript Array as a FIFO. Somewhere between 100,000 and
200,000 entries the program performance went to hell (dev host is a MBP
w/8GB RAM). 15 minutes later, I implemented a simple dequeue and my FIFO
scales up to millions of entries.

It is a drop-in replacement for javascript-arrays-as-fifo.

## Example: Dequeue as a replacement for an Array as a FIFO

    var Dequeue = require('dequeue')
    
    //var fifo = []
    var fifo = new Dequeue()
    
    fifo.length === 0 //=> true
    
    fifo.push(d1)
    fifo.length === 1 //=> true
    
    fifo.unshift(d2)
    
    fifo.pop() === d1 //=> true
    
    fifo.push(d3)
    
    fifo.shift() === d2 //=> true
    
    fifo.length === 1 //=> true; only d3 is in the dequeue
    
## API

### `deque = new Dequeue()`

### `deque.push(value)`
Push a value on the end.

### `value = deque.pop()`
Remove a value off the end.

### `deque.unshift(value)`
Push a value on the beginning.

### `value = deque.shift()`
Remove a value off the beginning.

### `value = deque.last()`
Examine the value of the end without removing it.

### `value = deque.first()`
Examine the value of the beginning without removing it.

### `deque.empty()`
Remove all entries. This is NOT a test for an empty dequeue; use `deque.length`
for that.

## Future Development
Something this simple does not really need a roadmap. However, I am thinking
of adding APIs to facilitate walking the Linked List via an iterator. It will
be simple and fully backward compatible.

## About the Code

I was convinced by [a blog posting](http://blog.izs.me/post/2353458699/an-open-letter-to-javascript-leaders-regarding) [by Issac Z. Schlueter](http://blog.izs.me/) that I don't need
semicolons. So I don't use them.

---
_Source: https://npm.io/package/dequeue · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
