Skip to content

@plinthjs/support ​

The foundation package for Plinth. Everything else in the framework depends on it; it depends on nothing.

What's here ​

ExportMirrorsNotes
Collection / collect()the usual designFluent, immutable, list-backed; map/filter/where/pluck/groupBy/sortBy/aggregates/partition/when/tap/pipe/…
Arrthe usual designwrap/first/last/flatten/pluck/only/except/keyBy/groupBy/chunk/get/set/has/…
Str / Stringable (Str.of)the usual designcase conversions, slug/limit/mask/before/after/start/finish/plural/singular/… + fluent chain
Numthe usual designformat/currency/percentage/ordinal/fileSize/abbreviate/clamp (via Intl)
Pipeline / pipeline()the usual designasync-first: pipes & destination may return promises
Tappable / Conditionable / Macroablethe corresponding traitsTypeScript mixin functions, composable
value / tap / blank / filled / dataGet / dataSetglobal helpersdot-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/support

Usage ​

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'

Released under the MIT License.