All Projects β†’ sindresorhus β†’ Yocto Queue

sindresorhus / Yocto Queue

Licence: mit
Tiny queue data structure

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Yocto Queue

P Queue
Promise queue with concurrency control
Stars: ✭ 1,863 (+989.47%)
Mutual labels:  queue, npm-package
quetie
πŸŽ€ Just the cutest and tiniest queue/deque implementation!
Stars: ✭ 111 (-35.09%)
Mutual labels:  queue, npm-package
Redux Data Structures
Reducer factory functions for common data structures: counters, maps, lists (queues, stacks), sets, etc.
Stars: ✭ 157 (-8.19%)
Mutual labels:  queue
Reactopt
A CLI React performance optimization tool that identifies potential unnecessary re-rendering
Stars: ✭ 1,975 (+1054.97%)
Mutual labels:  npm-package
Alfred Dark Mode
Alfred 3 workflow to toggle the system dark mode
Stars: ✭ 165 (-3.51%)
Mutual labels:  npm-package
Node Rethinkdb Job Queue
A persistent job or task queue backed by RethinkDB.
Stars: ✭ 158 (-7.6%)
Mutual labels:  queue
Holster
A place to keep useful golang functions and small libraries
Stars: ✭ 166 (-2.92%)
Mutual labels:  queue
Gh Got
Convenience wrapper for Got to interact with the GitHub API
Stars: ✭ 156 (-8.77%)
Mutual labels:  npm-package
New Github Issue Url
Generate a URL for opening a new GitHub issue with prefilled title, body, and other fields
Stars: ✭ 170 (-0.58%)
Mutual labels:  npm-package
Message Bus
Go simple async message bus
Stars: ✭ 166 (-2.92%)
Mutual labels:  queue
Typescript Transform Paths
Transforms absolute imports to relative
Stars: ✭ 166 (-2.92%)
Mutual labels:  npm-package
Laravel Rate Limited Job Middleware
A job middleware to rate limit jobs
Stars: ✭ 166 (-2.92%)
Mutual labels:  queue
Sc
Common libraries and data structures for C.
Stars: ✭ 161 (-5.85%)
Mutual labels:  queue
Into Stream
Convert a string/promise/array/iterable/asynciterable/buffer/typedarray/arraybuffer/object into a stream
Stars: ✭ 167 (-2.34%)
Mutual labels:  npm-package
Magic Iterable
Call a method on all items in an iterable by calling it on the iterable itself
Stars: ✭ 159 (-7.02%)
Mutual labels:  npm-package
Cash Cli
πŸ’°πŸ’° Convert currency rates directly from your terminal!
Stars: ✭ 168 (-1.75%)
Mutual labels:  npm-package
React Render In Browser
React library to render browser specific content
Stars: ✭ 157 (-8.19%)
Mutual labels:  npm-package
Acl
Server framework and network components written by C/C++ for Linux, Mac, FreeBSD, Solaris(x86), Windows, Android, IOS
Stars: ✭ 2,113 (+1135.67%)
Mutual labels:  queue
Interviewbit
Collection of Abhishek Agrawal's gists solutions for problems on https://www.interviewbit.com
Stars: ✭ 166 (-2.92%)
Mutual labels:  queue
Http Loader
A loader for ngx-translate that loads translations with http calls
Stars: ✭ 170 (-0.58%)
Mutual labels:  npm-package

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

const Queue = require('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.

Related

  • quick-lru - Simple β€œLeast Recently Used” (LRU) cache
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].