Skip to content

Control Flow

Control-flow helpers model how async tasks relate to one another. Use them when the workflow shape matters more than a single function call.

import { auto, queue, parallel, series } from "@vgerbot/async";
import { auto, queue } from "@vgerbot/async/control-flow";
API Description
auto Runs a dependency graph of named async tasks.
queue Creates a concurrency-limited worker queue for jobs pushed over time.
priorityQueue Processes queued jobs by priority.
parallel Runs independent tasks concurrently.
series Runs tasks sequentially.
waterfall Passes each task result into the next task.
race Resolves or rejects with the first settled task.
allSettled Waits for all tasks and returns every outcome.
any Resolves with the first successful task.
times Runs an async task a fixed number of times.
whilst Repeats while a condition remains true.
delay Creates a delayed async result.
timeout Applies a timeout to async work.
retry Retries async work according to retry options.
tryEach Tries tasks until one succeeds.
reflect Converts rejection into a resolved result object.
forever Repeats async work until it fails or is cancelled.