concurrent-delay
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

concurrent-delay

A class that provides a way to delay a task

Installation

via npm:

  $ npm install concurrent-delay

via yarn:

  $ yarn add concurrent-delay

Example

import { DelayRequest } from 'concurrent-delay';

// Use redis
const cDelay = new DelayRequest({ host: 'localhost', port: 6379 });

// Job delay every 2 seconds takes effect for 60 seconds
app.get('/task', async (req, res) => {
  await cDelay.delay({ ms: 2000, ttl: 60, key: 'abc' });
  res.send('ok');
});

API options

new DelayRequest(options)

Redis store for concurrent-delay, visit ioredis configuration

delay(options)
  • ms: Number Number of milliseconds delay
  • ttl: Number Time of seconds expires
  • key: String Key can be consumed by IP address, user ID, authorisation token, API route or any other string.

Package Sidebar

Install

npm i concurrent-delay

Weekly Downloads

0

Version

1.0.1

License

MIT

Unpacked Size

5.41 kB

Total Files

5

Last publish

Collaborators

  • khoatv