🇬🇧
  • Overview
  • @pdfking/tfunc
    • Async
    • Records
    • Sequences
    • Runtime
    • Types
  • @pdfking/structs
    • Runtime
    • Types
  • @pdfking/errors
    • Runtime
    • Types
  • @pdfking/math
    • Runtime
    • Types
  • @pdfking/taskmaker
    • Runtime
    • Types
  • @pdfking/planner
    • Runtime
    • Types
  • @pdfking/pdfengine
    • Runtime
    • Types

Async

Errors are values: SafePromise turns a promise that may reject into one that resolves to a result, and WithCleanup runs a cleanup either way.

import { SafePromise } from "@pdfking/tfunc"

const result = await SafePromise(Promise.reject(new Error("Failed")))
result.error?.enum // "INTERNAL_ERROR"
  • Wait: WaitPromises for an array or a record of promises, Sleep
  • Stream: MapAsync, FilterAsync, Collect
  • Share: Channel, Broadcast, LockManager

For plain iterables, see Sequences.