dumb-limiter

0.0.2 • Public • Published

dumb-limiter

A simple and performant limiter that executes your tasks in order with the possibility of parallelization (which is not the case of dumb-queue).

Install

npm install @pyrsmk/dumb-limiter

Usage

// Initialize the limiter with a wait time of 1000ms.
const limiter = require('dumb-limiter')(1000)

// The callback must return a promise so`the queue know when the task has finished.
limiter(() => someAsyncSlowAction1())
// ...
// Further in your code.
limiter(() => someAsyncSlowAction2())
// ...
// You can, of course, use non-async functions with the help of `async` which will
// always return a promise.
limiter(async () => someSyncSlowAction3())

The tasks are called as soon they are added to the limiter stack, anywhere in your app.

Compatibility

Node 8+

Readme

Keywords

Package Sidebar

Install

npm i dumb-limiter

Weekly Downloads

2

Version

0.0.2

License

MIT

Unpacked Size

1.71 kB

Total Files

4

Last publish

Collaborators

  • pyrsmk