stopcock
Pipe-based FP for TypeScript. Fuses array operations into single loops.
import { pipe, A } from '@stopcock/fp'
const topActive = pipe( players, A.filter(p => p.active && p.score > 0), A.map(p => ({ name: p.name, score: p.score })), A.take(10),)pipe spots that filter, map, and take can all run in one loop, so it fuses them. take(10) bails out after 10 hits. On a million-element array, that means touching a few dozen items instead of three full passes.
9xfilter→map→take(10) on 100K elements
10xfilter→map→take(10) on 100K elements
6xfilter→map→take(10) on 100K elements
import { pipe, O, R } from '@stopcock/fp'
const port = pipe( O.fromNullable(process.env.PORT), O.map(s => parseInt(s, 10)), O.filter(n => n > 0 && n < 65536), O.getOrElse(() => 3000),)
const parsed = pipe( R.tryCatch(() => JSON.parse(raw)), R.map(obj => obj.data), R.getOrElse(() => []),)Option for values that might not exist, Result for things that can fail. Both use numeric _tag instead of strings, so V8 can branch on them fast.
A Array S String D Dict N Number G Guards Obj Object M Math B Boolean Logic Logic Lens Lenses O Option R Result
Libraries
Section titled “Libraries”Standalone packages. They all work with pipe and with each other.
async Tasks & concurrency stream Lazy sequences validate Schema validation date Date utilities compress Compression algorithms encoding Base64, Hex, MsgPack hash SHA-256, MD5, CRC32 struct Data structures search Fuzzy, Trie, Bloom parse Parser combinators zip ZIP archives serve HTTP framework optics Lens, Prism, Iso geo Geospatial math rand RNG & distributions img Image processing
bun add @stopcock/fp