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.
LazySynchronous memoized thunk — runs once, caches the result for subsequent calls.
EqualityComposable equality checks; adapt to fields with by, combine with and.
OrderingComposable sort comparators; chain with thenBy, flip with reverse, adapt with by.
CombinableMonoid algebra — fold collections and combine values with a neutral starting point.

import from @nlozgachev/pipelined/data

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.
DurationRepresent and manipulate time durations (seconds, milliseconds, etc.).
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.
uncurryConvert a curried function to accept a tuple/list of arguments.
flipReverse the order of the first two arguments of a function.
convergeApply a list of unary functions to a value, combining results with a binary/n-ary function.
juxtApply multiple functions to the same arguments, returning an array of results.
onTransform two arguments with a unary function, then apply them to a binary function.