Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

dequeue

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dequeue

A simple double ended queue datastructure

  • 1.0.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
5.2K
decreased by-78.87%
Maintainers
1
Weekly downloads
 
Created
Source

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.

I was convinced by a blog posting by Issac Z. Schlueter that I don't need semicolons. So I don't use them.

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

Keywords

FAQs

Package last updated on 08 Jul 2012

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc