API Reference
The library is split into four entry points. Each is independently importable.
import from @nlozgachev/pipelined/core
| Type | Description |
|---|---|
| Maybe | A value that may or may not exist. Replaces T | null | undefined. |
| Result | An operation that succeeds with a value or fails with an error. |
| Op | A reusable async operation with typed outcomes and managed execution. |
| Validation | Like Result, but accumulates all errors instead of stopping at the first. |
| Task | A lazy, infallible async operation. |
| TaskResult | A lazy async operation that can fail. |
| TaskMaybe | A lazy async operation that may return nothing. |
| TaskValidation | A lazy async operation that accumulates errors. |
| RemoteData | The four states of a data fetch: NotAsked, Loading, Failure, Success. |
| Deferred | A minimal async value that always resolves — no rejection handling needed. |
| These | An inclusive-OR: holds a first value, a second value, or both simultaneously. |
| Tuple | A typed pair where both values are always present. |
| Lens | Focus on and immutably update a required nested field. |
| Optional | Focus on and update an optional nested field or array index. |
| Reader | Computations that read from a shared environment without threading it everywhere. |
| State | Thread mutable state through a pipeline without explicit passing. |
| Logged | A value paired with an accumulated log; thread logs through a pipeline. |
| Predicate | Composable boolean checks; combine with and, or, not. |
| Refinement | Type predicates with runtime validation; narrows a broad type to a specific one. |
| Resource | Safe acquire-use-release lifecycle; guarantees cleanup even when errors occur. |
import from @nlozgachev/pipelined/utils
| Module | Description |
|---|---|
| Arr | Array utilities (find, groupBy, zip, partition) that return Maybe instead of throwing. |
| Dict | Build, look up, and transform key-value maps. |
| Num | Number utilities: clamp, range, sum, and arithmetic helpers. |
| Rec | Record/object utilities: pick, omit, mapValues, and key transformations. |
| Str | String utilities: trim, split, capitalize, and parsing helpers. |
| Uniq | Deduplicate and manage sets represented as arrays. |
import from @nlozgachev/pipelined/types
| Type | Description |
|---|---|
| Brand | Nominal typing — prevents mixing values that share the same underlying type. |
| NonEmptyList | An array guaranteed to have at least one element. |
Composition
Section titled “Composition”import from @nlozgachev/pipelined/composition
| Function | Description |
|---|---|
| pipe | Pass a value through a sequence of functions, left to right. |
| flow | Compose functions into a reusable pipeline. |
| compose | Compose functions right to left. |
| tap | Run a side effect without breaking the pipeline. |
| curry | Convert a multi-argument function into a chain of single-argument functions. |
| memoize | Cache function results by argument. |
| identity | Return the argument unchanged. |
| constant | Return a function that always returns the same value. |
| not | Negate a predicate function. |
| once | Call a function at most once; return the cached result thereafter. |