npm

Ready to take your JavaScript development to the next level? Meet npm Enterprise - the ultimate in enterprise JavaScript.Learn more »

@soncodi/reqqueue

1.0.2 • Public • Published

ReqQueue

Build Status Coverage Status Dependency Status npm version

Sequential request queue for Node.js and browsers

  • 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

import { ReqQueue } from '@soncodi/reqqueue';
// or
const { ReqQueue } = require('@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

3

version

1.0.2

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability