Skip to content

API Reference

The library is split into four entry points. Each is independently importable.

import from @nlozgachev/pipelined/core

TypeDescription
MaybeA value that may or may not exist. Replaces T | null | undefined.
ResultAn operation that succeeds with a value or fails with an error.
OpA reusable async operation with typed outcomes and managed execution.
ValidationLike Result, but accumulates all errors instead of stopping at the first.
TaskA lazy, infallible async operation.
TaskResultA lazy async operation that can fail.
TaskMaybeA lazy async operation that may return nothing.
TaskValidationA lazy async operation that accumulates errors.
RemoteDataThe four states of a data fetch: NotAsked, Loading, Failure, Success.
DeferredA minimal async value that always resolves — no rejection handling needed.
TheseAn inclusive-OR: holds a first value, a second value, or both simultaneously.
TupleA typed pair where both values are always present.
LensFocus on and immutably update a required nested field.
OptionalFocus on and update an optional nested field or array index.
ReaderComputations that read from a shared environment without threading it everywhere.
StateThread mutable state through a pipeline without explicit passing.
LoggedA value paired with an accumulated log; thread logs through a pipeline.
PredicateComposable boolean checks; combine with and, or, not.
RefinementType predicates with runtime validation; narrows a broad type to a specific one.
ResourceSafe acquire-use-release lifecycle; guarantees cleanup even when errors occur.

import from @nlozgachev/pipelined/utils

ModuleDescription
ArrArray utilities (find, groupBy, zip, partition) that return Maybe instead of throwing.
DictBuild, look up, and transform key-value maps.
NumNumber utilities: clamp, range, sum, and arithmetic helpers.
RecRecord/object utilities: pick, omit, mapValues, and key transformations.
StrString utilities: trim, split, capitalize, and parsing helpers.
UniqDeduplicate and manage sets represented as arrays.

import from @nlozgachev/pipelined/types

TypeDescription
BrandNominal typing — prevents mixing values that share the same underlying type.
NonEmptyListAn array guaranteed to have at least one element.

import from @nlozgachev/pipelined/composition

FunctionDescription
pipePass a value through a sequence of functions, left to right.
flowCompose functions into a reusable pipeline.
composeCompose functions right to left.
tapRun a side effect without breaking the pipeline.
curryConvert a multi-argument function into a chain of single-argument functions.
memoizeCache function results by argument.
identityReturn the argument unchanged.
constantReturn a function that always returns the same value.
notNegate a predicate function.
onceCall a function at most once; return the cached result thereafter.