Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including @mrnkr/simple-queue with all npm packages installed. Try it out:

var simpleQueue = require("@mrnkr/simple-queue")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

@mrnkr/simple-queue v1.0.5

Minimal queue implementation

simple-queue

Introduction

The smallest possible implementation of a queue. Need simplicity? Here it is. 100% code coverage in tests, all alternatives I could think of are taken into consideration as well. Hence, it is as robust as it can be... (that statement may backfire, be gentle 😅)

Quick start

The specification is the following:

export interface Queue<T> {

  enqueue(val: T): void;
  next(): T | undefined;

  length: number;

}

All methods do exactly what they are meant to do in the provided implementation (QueueImpl). You may reimplement this interface, extend it, do as you wish, really.

Metadata

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free