Skip to main content

Overview

The library functions return a result that avoids exceptions and facilitates flow control.
  • run returns an object with ok: true and data, or ok: false and error.
  • all returns an array with results per task: ok, error or skipped.
  • Optional metrics help observe attempts, retries, and duration.

RunResult in run

Result structure:
  • Success: { ok: true, data, error: null, metrics? }
  • Error: { ok: false, data: null, error, metrics? }
Metrics include:
  • totalAttempts
  • totalRetries
  • totalDuration
  • lastError?

RunAllItemResult in all

Possible states per item:
  • ok: successful task with data
  • error: failed task with error
  • skipped: task not rund due to cancellation or fail-fast

Type helpers for all

The library exports utilities to discriminate results and improve typing: