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 1,000,000+ packages pre-installed, including @soncodi/reqqueue with all npm packages installed. Try it out:

var reqqueue = require("@soncodi/reqqueue")

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

@soncodi/reqqueue v1.0.5

Sequential request queue for Node.js and browsers.

ReqQueue

Build Status Coverage Status Dependency Status npm version

Sequential request queue for Node.js and browsers. No dependencies.

  • Requests are executed in the order in which they were queued
  • Execution of requests is sequential (not interleaved)
  • Supports requests with both sync and async results

Installation

npm install @soncodi/reqqueue --save

Usage (TypeScript)

import { ReqQueue } from '@soncodi/reqqueue';

const q = new ReqQueue(false);

const request = async () => {
  await new Promise(resolve => setTimeout(resolve, Math.random() * 1000));

  return Math.random();
};

const [a, b, c] = await Promise.all([
  q.add(request);
  q.add(request);
  q.add(request);
]);

Methods

add<T>(fn: (...args: any[]) => T|Promise<T>): Promise<T>

Adds a request to the request queue to be executed.

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