Big update!Announcing Socket for GitHub 1.0. Learn more
Socket
BlogLoveFAQ
Install
Log in

yocto-queue

Package Overview
Dependencies
0
Maintainers
1
Versions
3
Issues
File Explorer

Advanced tools

yocto-queue

Tiny queue data structure

    1.0.0latest

Version published
Maintainers
1
Weekly downloads
17,291,542
decreased by-1.57%

Weekly downloads

Changelog

Source

Breaking

  • Require Node.js 12.20 0228034
  • This package is now pure ESM. Please read this.

https://github.com/sindresorhus/yocto-queue/compare/v0.1.0...v1.0.0

Readme

Source

yocto-queue

Tiny queue data structure

You should use this package instead of an array if you do a lot of Array#push() and Array#shift() on large arrays, since Array#shift() has linear time complexity O(n) while Queue#dequeue() has constant time complexity O(1). That makes a huge difference for large arrays.

A queue is an ordered list of elements where an element is inserted at the end of the queue and is removed from the front of the queue. A queue works based on the first-in, first-out (FIFO) principle.

Install

$ npm install yocto-queue

Usage

import Queue from 'yocto-queue'; const queue = new Queue(); queue.enqueue('🦄'); queue.enqueue('🌈'); console.log(queue.size); //=> 2 console.log(...queue); //=> '🦄 🌈' console.log(queue.dequeue()); //=> '🦄' console.log(queue.dequeue()); //=> '🌈'

API

queue = new Queue()

The instance is an Iterable, which means you can iterate over the queue front to back with a “for…of” loop, or use spreading to convert the queue to an array. Don't do this unless you really need to though, since it's slow.

.enqueue(value)

Add a value to the queue.

.dequeue()

Remove the next value in the queue.

Returns the removed value or undefined if the queue is empty.

.clear()

Clear the queue.

.size

The size of the queue.

  • quick-lru - Simple “Least Recently Used” (LRU) cache

Keywords

FAQs

What is yocto-queue?

Tiny queue data structure

Is yocto-queue popular?

The npm package yocto-queue receives a total of 14,071,998 weekly downloads. As such, yocto-queue popularity was classified as popular.

Is yocto-queue well maintained?

We found that yocto-queue demonstrated a not healthy version release cadence and project activity because the last version was released a year ago.It has 1 open source maintainer collaborating on the project.

Last updated on 12 Aug 2021
Socket

Product

Subscribe to our newsletter

Get open source security insights delivered straight into your inbox. Be the first to learn about new features and product updates.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc