@effectionx/task-buffer@1.0.2Built and signed on GitHub ActionsBuilt and signed on GitHub Actions
Built and signed on GitHub Actions
latest
Rate limit the number of concurrent tasks in Effection programs.
This package works with Node.js, Deno, Bun, BrowsersIt is unknown whether this package works with Cloudflare Workers




JSR Score
100%
Published
3 months ago (1.0.2)
Task Buffer
Manages concurrent task execution by enforcing a maximum limit on simultaneously active operations.
When this limit is reached, the TaskBuffer
automatically queues additional
spawn requests and processes them in order as capacity becomes available. This
prevents resource overload while ensuring all tasks are eventually executed.
import { run, sleep } from "effection"; import { useTaskBuffer } from "@effectionx/task-buffer"; await run(function* () { // Create a task buffer with a maximum of 2 concurrent tasks const buffer = yield* useTaskBuffer(2); // These tasks will execute immediately since they're within the limit yield* buffer.spawn(() => sleep(10)); yield* buffer.spawn(() => sleep(10)); // This task will be queued until one of the running tasks completes yield* buffer.spawn(() => sleep(10)); // Wait for this specific task to complete yield* yield* buffer.spawn(() => sleep(10)); // Wait for all spawned tasks to complete yield* buffer; });
Built and signed on
GitHub Actions
Add Package
deno add jsr:@effectionx/task-buffer
Import symbol
import * as task_buffer from "@effectionx/task-buffer";
Import directly with a jsr specifier
import * as task_buffer from "jsr:@effectionx/task-buffer";
Add Package
pnpm i jsr:@effectionx/task-buffer
pnpm dlx jsr add @effectionx/task-buffer
Import symbol
import * as task_buffer from "@effectionx/task-buffer";
Add Package
yarn add jsr:@effectionx/task-buffer
yarn dlx jsr add @effectionx/task-buffer
Import symbol
import * as task_buffer from "@effectionx/task-buffer";
Add Package
vlt install jsr:@effectionx/task-buffer
Import symbol
import * as task_buffer from "@effectionx/task-buffer";
Add Package
npx jsr add @effectionx/task-buffer
Import symbol
import * as task_buffer from "@effectionx/task-buffer";
Add Package
bunx jsr add @effectionx/task-buffer
Import symbol
import * as task_buffer from "@effectionx/task-buffer";