task-simple-limiter
TypeScript icon, indicating that this package has built-in type declarations

3.3.0 • Public • Published

Task Simple Limiter

github action github action Coverage Status

本包可以方便的给异步任务限流,也就是并发控制。

Task Simple Limiter can control your tasks concurrency conveniently.

用例 Usage

初始化 Initialization

import Limiter from 'task-simple-limiter';

const limiter = new Limiter({ concurrency: 2 });

阻塞任务来限流 Blocking Task

async function task() {
  const release = await limiter.hold();
  try {
    await somethingAsync();
  }
  finally {
    release();
  }
}

链接 Links

  • concurrency-limiter

    限制并发的实现方式与本包类似。

    The way to control concurrency is similar to this package.

/task-simple-limiter/

    Package Sidebar

    Install

    npm i task-simple-limiter

    Weekly Downloads

    1

    Version

    3.3.0

    License

    GPL-2.0-or-later

    Unpacked Size

    26.2 kB

    Total Files

    6

    Last publish

    Collaborators

    • e0selmy4v