dequeue
A simple double ended queue datastructure
Last updated 14 years ago by lleo .
Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install dequeue 
SYNC missed versions from official npm registry.

A Simple Double Ended Queue Datastructure

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 dropin replacement for javascript-arrays-as-fifo.

BTW, I use Felix's Node.js Style Guide; get over it ;)

So here is the API:

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

Current Tags

  • 1.0.5                                ...           latest (13 years ago)

6 Versions

  • 1.0.5                                ...           13 years ago
  • 1.0.4                                ...           13 years ago
  • 1.0.3                                ...           14 years ago
  • 1.0.2                                ...           14 years ago
  • 1.0.1                                ...           14 years ago
  • 1.0.0                                ...           14 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 1
Last Month 7
Dependencies (0)
None
Dev Dependencies (0)
None
Dependents (1)

Copyright 2013 - present © cnpmjs.org | Home |