@ludoows/tubby
v1.0.0
Published
Pipeline orchestrator for TypeScript. Lightweight, expressive, fully typed.
Maintainers
Readme
@ludoows/tubby
Pipeline orchestrator for TypeScript — lightweight, expressive, fully typed.
npm install @ludoows/tubbyWhat it does
Compose async operations as a sequence of typed steps. Each step receives a payload, does its thing, and hands it to the next.
import { pipeline, map, tap, retry, timeout } from '@ludoows/tubby'
const result = await pipeline({ orderId: '123', total: 99 })
.give({ userId: 'u_42' })
.ensure((order) => order.total > 0, 'Empty order')
.through([
validateStock,
retry(timeout(chargePayment, 5000), { attempts: 3 }),
tap((order) => logger.info('charged', order.orderId)),
sendConfirmation,
])
.thenReturn()No magic. No decorators. Just functions and objects.
Features
- Chainable builder API (
pipeline().give().through().thenReturn()) - Typed payload and context throughout the chain
- Step-level error recovery with
onError - Guards with
ensure(), early exit withstop() - Built-in utilities:
map,tap,branch,when,unless,retry,timeout,delay,merge,pick,parallel,combine,once,race,fallback,loop - Abort support via
.withSignal(AbortSignal) - Real-time step streaming with
.thenStream() - Observability:
inspect(),measure(),onStep(),collect()
TypeScript
Payload and context types flow end-to-end with no manual casting:
type Order = { id: string; total: number }
type Ctx = { userId: string }
const result = await pipeline<Order>({ id: '1', total: 50 })
.give<Ctx>({ userId: 'u_1' })
.through([myStep]) // Step<Order, Ctx> — fully checked
.thenReturn() // Order | nullCDN
<!-- development -->
<script src="https://cdn.jsdelivr.net/npm/@ludoows/tubby/dist/index.global.js"></script>
<!-- production (minified) -->
<script src="https://cdn.jsdelivr.net/npm/@ludoows/tubby/dist/index.global.min.js"></script>
<script>
const { pipeline, tap, retry } = Tubby
</script>Documentation
→ Getting started · Full API · Utilities
