# queue-lit

> queue-lit is a tiny queue data structure in case you `Array#push()` or `Array#shift()` on large arrays very often

Latest version **3.3.0** (published 2026-06-28) · MIT license · 0 weekly downloads

## Install

```sh
npm install queue-lit
pnpm add queue-lit
yarn add queue-lit
bun add queue-lit
```

## Health

**Score 70/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; recently updated; high maintenance score; high quality score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 3.3.0 |
| Published | 2026-06-28 |
| First published | 2021-04-04 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=18 |
| Dependencies | 0 |
| Unpacked size | 6.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Joel Voss |
| Maintainers | joelvoss |

## Links

- npm: https://www.npmjs.com/package/queue-lit
- Repository: https://github.com/joelvoss/queue-lit
- Issues: https://github.com/joelvoss/queue-lit/issues
- npm.io page: https://npm.io/package/queue-lit

## Recent versions

- 3.3.0 (latest) — 2026-06-28
- 3.2.2 — 2026-05-09
- 3.2.1 — 2026-04-07
- 3.2.0 — 2026-04-07
- 3.1.0 — 2026-03-23
- 3.0.0 — 2024-05-15
- 2.0.0 — 2023-10-05
- 1.5.2 — 2023-10-05
- 1.5.1 — 2023-10-03
- 1.5.0 — 2022-11-06
- 1.4.0 — 2022-09-05
- 1.3.0 — 2022-07-24
- 1.2.8 — 2022-06-06
- 1.2.7 — 2022-04-20
- 1.2.6 — 2022-02-26
- … 12 more at https://npm.io/package/queue-lit/versions

## README

# queue-lit

This package is a tiny queue data structure in case you `Array#push()` or
`Array#shift()` on large arrays very often.  
`Array#shift()` has linear time complexity `O(n)` while `Queue#push()` has
constant time complexity `O(1)`.

## Installation

```bash
$ npm i queue-lit
# or
$ yarn add queue-lit
```

## Usage

```js
import { Queue } from 'queue-lit';

const queue = new Queue();

queue.push('Hello');
queue.push('World');

console.log(queue.size);
// => 2

console.log(...queue);
// => 'Hello World'

console.log(queue.pop());
//=> 'Hello'

console.log(queue.pop());
//=> 'World'
```

## 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.

#### `.push(value)`

Adds one element to the end of the queue and returns the new length of
the queue.  
This method changes the size of the queue.

#### `.pop()`

Pop removes the last element from the queue and returns that element.  
This method changes the size of the queue.

Returns `undefined` if the queue is empty.

#### `.clear()`

Clears the queue and removes all elements.  
This method changes the size of the queue.

#### `.size`

Static method that returns the size of the queue.


## Development

(1) Install dependencies

```bash
$ npm i
```

(2) Run initial validation

```bash
$ ./Taskfile.sh validate
```

(3) Start developing. See [`./Taskfile.sh`](./Taskfile.sh) for more tasks to
    help you develop.

---

[`Iterable`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols

---
_Source: https://npm.io/package/queue-lit · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
