API Reference
The library is split into three entry points. Each is independently importable.
import from @nlozgachev/pipekit/Core
| Type | Description |
|---|---|
| Option | 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. |
| Validation | Like Result, but accumulates all errors instead of stopping at the first. |
| Task | A lazy async operation. |
| TaskResult | A lazy async operation that can fail. |
| TaskOption | 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. |
| These | An inclusive-OR: holds an error, a value, or both simultaneously. |
| Arr | Array utilities that return Option instead of throwing or returning undefined. |
| Rec | Record/object utilities. |
import from @nlozgachev/pipekit/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/pipekit/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. |