npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@ch1nm4y-8/simple-queue-js

v1.0.1

Published

A lightweight FIFO queue for JavaScript and TypeScript

Downloads

62

Readme

@ch1nm4y-8/simple-queue-js

A lightweight FIFO queue for JavaScript and TypeScript.

Features

  • Zero runtime dependencies
  • FIFO (First In, First Out)
  • Full TypeScript support with type declarations
  • Supports ESM (import)
  • Supports CommonJS (require)
  • Iterable (for...of, Array.from, spread operator)
  • Clone support
  • Array conversion support

Install

npm install @ch1nm4y-8/simple-queue-js

TypeScript

import { Queue } from "@ch1nm4y-8/simple-queue-js";

const queue = new Queue<number>();

queue.enqueue(1);
queue.enqueue(2);
queue.enqueue(3);

console.log(queue.dequeue()); // 1
console.log(queue.peek()); // 2
console.log(queue.size()); // 2

Constructor

const queue1 = new Queue([1, 2, 3]);
const queue2 = new Queue(new Set([1, 2, 3]));

console.log(queue1.dequeue()); // 1

Iteration

const queue = new Queue([1, 2, 3]);

for (const item of queue) {
  console.log(item);
}
// 1
// 2
// 3

Type Safety

const queue = new Queue<number>();

queue.enqueue(1);

// Type Error
queue.enqueue("hello");

ECMAScript Modules (ESM)

import { Queue } from "@ch1nm4y-8/simple-queue-js";

const queue = new Queue();

queue.enqueue("A");
queue.enqueue("B");

console.log(queue.dequeue()); // A

CommonJS

const { Queue } = require("@ch1nm4y-8/simple-queue-js");

const queue = new Queue();

queue.enqueue("A");
queue.enqueue("B");

console.log(queue.dequeue()); // A

API

| Method | Time Complexity | Description | | ---------------- | --------------- | ------------------------------------------ | | enqueue(value) | O(1) | Adds an item to the back of the queue | | dequeue() | O(1) amortized | Removes and returns the front item | | peek() | O(1) | Returns the front item without removing it | | clear() | O(1) | Removes all items | | size() | O(1) | Returns the number of items | | isEmpty() | O(1) | Returns whether the queue is empty | | toArray() | O(n) | Converts the queue to an array | | clone() | O(n) | Returns a shallow copy of the queue |

enqueue(value)

Adds an item to the back of the queue.

queue.enqueue(1);

Returns:

this;

dequeue()

Removes and returns the front item.

const value = queue.dequeue();

Returns:

T | undefined;

peek()

Returns the front item without removing it.

const value = queue.peek();

Returns:

T | undefined;

clear()

Removes all items from the queue.

queue.clear();

Returns:

void

size()

Returns the number of items in the queue.

console.log(queue.size());

Returns:

number;

isEmpty()

Returns whether the queue is empty.

console.log(queue.isEmpty());

Returns:

boolean;

toArray()

const queue = new Queue([1, 2, 3]);
console.log(queue.toArray()); // [1, 2, 3]

clone()

const q1 = new Queue([1, 2, 3]);
const q2 = q1.clone();

q1.dequeue();

console.log(q1.toArray()); // [2, 3]
console.log(q2.toArray()); // [1, 2, 3]

Example

import { Queue } from "@ch1nm4y-8/simple-queue-js";

const tasks = new Queue<string>();

tasks.enqueue("Build");
tasks.enqueue("Test");
tasks.enqueue("Deploy");

while (!tasks.isEmpty()) {
  console.log(tasks.dequeue());
}

Output:

Build
Test
Deploy

License

MIT