Miss any of our Open RFC calls?Watch the recordings here! »

@soncodi/reqqueue

1.0.5 • Public • Published

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.

Install

npm i @soncodi/reqqueue

DownloadsWeekly Downloads

6

Version

1.0.5

License

MIT

Unpacked Size

9.25 kB

Total Files

5

Last publish

Collaborators

  • avatar