@plinthjs/support
The foundation package for Plinth. Everything else in the framework depends on it; it depends on nothing.
What's here
| Export | Mirrors | Notes |
|---|---|---|
Collection / collect() | the usual design | Fluent, immutable, list-backed; map/filter/where/pluck/groupBy/sortBy/aggregates/partition/when/tap/pipe/… |
Arr | the usual design | wrap/first/last/flatten/pluck/only/except/keyBy/groupBy/chunk/get/set/has/… |
Str / Stringable (Str.of) | the usual design | case conversions, slug/limit/mask/before/after/start/finish/plural/singular/… + fluent chain |
Num | the usual design | format/currency/percentage/ordinal/fileSize/abbreviate/clamp (via Intl) |
Pipeline / pipeline() | the usual design | async-first: pipes & destination may return promises |
Tappable / Conditionable / Macroable | the corresponding traits | TypeScript mixin functions, composable |
value / tap / blank / filled / dataGet / dataSet | global helpers | dot-path access with * wildcards |
Lazy collections (
LazyCollection) and the long tail of less-common methods land in a later Tier-1 pass. This is the high-frequency core, fully tested (81 tests).
Install
bash
pnpm add @plinthjs/supportUsage
ts
import { collect, Str, Num, Arr, pipeline } from '@plinthjs/support'
collect([1, 2, 3, 4])
.filter((n) => n % 2 === 0)
.map((n) => n * 10)
.sum() // 60
Str.of(' Hello World ').trim().slug().value // 'hello-world'
Num.currency(12.5) // '$12.50'
Arr.get({ user: { name: 'Ada' } }, 'user.name') // 'Ada'
await pipeline<number>()
.send(1)
.through([(n, next) => next(n + 1), (n, next) => next(n * 10)])
.then((n) => `result: ${n}`) // 'result: 20'