@plinthjs/support
v0.1.0
Published
Mason foundation: collections, fluent string/array/number helpers, pipeline, and shared utilities.
Maintainers
Readme
@plinthjs/support
The foundation package for Mason. Everything else in the framework depends on it; it depends on nothing.
What's here
| Export | Mirrors | Notes |
| ------------------------------------------------------------ | ------------------------------- | ------------------------------------------------------------------------------------------------------------------------------ |
| Collection / collect() | Illuminate\Support\Collection | Fluent, immutable, list-backed; map/filter/where/pluck/groupBy/sortBy/aggregates/partition/when/tap/pipe/… |
| Arr | Illuminate\Support\Arr | wrap/first/last/flatten/pluck/only/except/keyBy/groupBy/chunk/get/set/has/… |
| Str / Stringable (Str.of) | Illuminate\Support\Str | case conversions, slug/limit/mask/before/after/start/finish/plural/singular/… + fluent chain |
| Num | Illuminate\Support\Number | format/currency/percentage/ordinal/fileSize/abbreviate/clamp (via Intl) |
| Pipeline / pipeline() | Illuminate\Pipeline | 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
pnpm add @plinthjs/supportUsage
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'