JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 12
  • Score
    100M100P100Q92775F
  • License AGPL-3.0-or-later

Functional programming library for TypeScript. Available under AGPL-3.0 or Commercial License.

Package Exports

  • @zambit/elevate-ts
  • @zambit/elevate-ts/Either
  • @zambit/elevate-ts/EitherAsync
  • @zambit/elevate-ts/Function
  • @zambit/elevate-ts/List
  • @zambit/elevate-ts/Maybe
  • @zambit/elevate-ts/MaybeAsync
  • @zambit/elevate-ts/NonEmptyList
  • @zambit/elevate-ts/Reader
  • @zambit/elevate-ts/State
  • @zambit/elevate-ts/Tuple
  • @zambit/elevate-ts/Validation

Readme

elevate-ts

Coverage npm License: AGPL%20v3%2B

Point-free, data-last functional programming for TypeScript. Fantasy Land 5 compliant. Zero dependencies. Cloudflare Workers ready.

Install

pnpm add @zambit/elevate-ts

Quick Start

import { pipe } from '@zambit/elevate-ts/Function';
import { Just, Nothing, map, chain } from '@zambit/elevate-ts/Maybe';

/** Create a Just value */
const ma = Just(5);

/** Use pipe to compose operations */
const result = pipe(
  ma,
  map((a) => a * 2),
  chain((b) => (b > 5 ? Just(b) : Nothing))
);

// result is Just(10)

Modules

Module Description
Maybe Optional values; Functor, Applicative, Monad, Alt, Filter
Either Values with a Left error branch; Bifunctor, Monad, Alt
Validation Functor for collecting all errors during applicative (not short-circuit)
Reader Dependency injection / environment access; Monad
State Pure stateful computation; track state through a sequence of operations
Tuple Immutable 2-tuple; Bifunctor, Monoid
NonEmptyList Guaranteed-nonempty array; Functor, Applicative, Monad, Monoid
List Utilities over plain readonly arrays; map, filter, partition, zip, etc.
Function Function composition and utilities; pipe, flow, curry, memoize, once, tap
MaybeAsync Lazy async Maybe; rejects or throws become Nothing; never rejects
EitherAsync Lazy async Either; rejects become Left; never throws

Philosophy

  • Point-free: Functions are composed by shape, not by naming intermediate values
  • Data-last: Configuration arguments precede the data being transformed
  • Pure: No classes, no mutations, ≤15 lines per function
  • Cloudflare Workers: No Node.js built-ins, no DOM APIs
  • Fantasy Land 5: All applicable types implement the spec
  • Zero runtime dependencies: Ship only pure TypeScript

Learning & Examples

  • elevate-ts-learning - Comprehensive tutorial with interactive todo app and 4 learning guides
  • elevate-ts-samples - Production-ready examples (form validation, state management, list operations, workers)

Roadmap

  • Audit subsystem with time-travel replay (will use @paralleldrive/cuid2 for operation-level ID stamping)

Contributing

See CONTRIBUTING.md for details on how to contribute. Non-trivial contributions must be covered by the applicable contributor license agreement: CLA-INDIVIDUAL.md or CLA-CORPORATE.md.

License

Dual-licensed:

  • Public license: GNU Affero General Public License v3.0 or later (AGPL-3.0-or-later). See LICENSE.
  • Commercial license: available from Zambit for customers who want to use elevate-ts in closed-source products or services. See COMMERCIAL-LICENSE.md.