> For AI agents: the complete documentation index is available at https://massaman.dev/llms.txt, the full documentation bundle is available at https://massaman.dev/llms-full.txt.

# massaman

Functional programming utilities for TypeScript. Rust's `match` and `Result` in TypeScript, layered over [`es-toolkit`](https://es-toolkit.dev) and [`ts-pattern`](https://github.com/gvergnaud/ts-pattern).

```bash
npm install massaman
```

```typescript
import { match, P, attempt, isOk } from 'massaman'

const result = attempt(() => JSON.parse(input))

const message = match(result)
  .with({ ok: true }, ({ value }) => `parsed ${typeof value}`)
  .with({ ok: false }, ({ error }) => `failed: ${error.message}`)
  .exhaustive()
```

## Where to start

- **[Introduction](https://massaman.dev/introduction.md)** — what's bundled, what's original
- **[Installation & usage](https://massaman.dev/installation.md)** — install, imports, tree-shaking
- **[Philosophy](https://massaman.dev/philosophy.md)** — the FP stance, why no classes / no throws / no switch
- **Concepts** — short guides on the core ideas:
  - [Result & Errors](https://massaman.dev/concepts/result.md)
  - [Pattern matching](https://massaman.dev/concepts/match.md)
  - [Composition](https://massaman.dev/concepts/composition.md)
- **Reference** — every export, by area:
  - [array](https://massaman.dev/reference/array.md) · [object](https://massaman.dev/reference/object.md) · [function](https://massaman.dev/reference/function.md) · [math](https://massaman.dev/reference/math.md) · [string](https://massaman.dev/reference/string.md) · [promise](https://massaman.dev/reference/promise.md) · [error](https://massaman.dev/reference/error.md)
  - [predicate](https://massaman.dev/reference/predicate.md) · [control](https://massaman.dev/reference/control.md) · [conversion](https://massaman.dev/reference/conversion.md) · [match](https://massaman.dev/reference/match.md)
