Socket
Socket
Sign inDemoInstall

tiny-queue

Package Overview
Dependencies
0
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    tiny-queue

Simple FIFO queue implementation to avoid having to do shift() on an array, which is slow.


Version published
Weekly downloads
35K
decreased by-30.96%
Maintainers
1
Install size
14.5 kB
Created
Weekly downloads
 

Readme

Source

tiny-queue

A simple FIFO queue implementation to avoid having to do shift() on an array, which is slow. It's implemented in the straightforward root -> node1 -> node2 -> etc. architecture that we all wrote in CS 101.

This can typically be used as a drop-in replacement for an array, and it's only 24 lines of code.

Usage:

npm install tiny-queue

Then:

var Queue = require('tiny-queue');
var queue = new Queue();

queue.push('foo');
queue.push('bar');
queue.shift(); // 'foo'
queue.shift(); //'bar'
queue.length; // 0
queue.shift(); // undefined

The returned Queue object, once instantiated, only supports three operations:

queue.push()
queue.shift()
queue.length

So it's basically a drop-in replacement for most naïve usages of an array as a queue.

Keywords

FAQs

Last updated on 23 May 2014

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc