async-sema

  • Version 3.1.0
  • Published
  • 13.5 kB
  • No dependencies
  • MIT license

Install

npm i async-sema
yarn add async-sema
pnpm add async-sema

Overview

Semaphore using `async` and `await`

Index

Functions

function RateLimit

RateLimit: (
rps: number,
{
timeUnit,
uniformDistribution,
}?: { timeUnit?: number; uniformDistribution?: boolean }
) => () => Promise<void>;

    Classes

    class Sema

    class Sema {}

      constructor

      constructor(
      nr: number,
      {
      initFn,
      pauseFn,
      resumeFn,
      capacity,
      }?: {
      initFn?: () => any;
      pauseFn?: () => void;
      resumeFn?: () => void;
      capacity?: number;
      }
      );

        method acquire

        acquire: () => Promise<any>;

          method drain

          drain: () => Promise<any[]>;

            method nrWaiting

            nrWaiting: () => number;

              method release

              release: (token?: any) => void;

                method tryAcquire

                tryAcquire: () => any | undefined;

                  Package Files (1)

                  Dependencies (0)

                  No dependencies.

                  Dev Dependencies (8)

                  Peer Dependencies (0)

                  No peer dependencies.

                  Badge

                  To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

                  You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/async-sema.

                  • Markdown
                    [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/async-sema)
                  • HTML
                    <a href="https://www.jsdocs.io/package/async-sema"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>