For AI agents: the complete documentation index is available at /llms.txt, the full documentation bundle is available at /llms-full.txt, and this page is available as Markdown at /index.md.
v0.5.0 · MIT

A rich blend of functional patterns.

A functional TypeScript utility library with Rust-inspired Result types and exhaustive pattern matching, built on es-toolkit and ts-pattern.

Split TypeScript editor showing match and attemptAsync with Result handling
built ones-toolkitts-patternTypeScript
Result + pattern matching

Handle failure as data.

One task, written both ways. Assume fetchUser() throws a Response on HTTP failure.

Exceptions, then manual narrowing

The catch block receives unknown, so every branch has to re-establish what the failure was before it can say anything about it.

  • message is a let, reassigned across branches
  • unknown must be narrowed before the status is readable
  • Nothing tells you when a case is missing
let message: string

try {
  const user = await fetchUser(userId)
  message = `Welcome, ${user.name}`
} catch (error: unknown) {
  if (error instanceof Response) {
    if (error.status === 404) {
      message = 'User not found'
    } else if (error.status >= 500) {
      message = 'The service is unavailable'
    } else {
      message = `Request failed: ${error.status}`
    }
  } else if (error instanceof Error) {
    message = `Could not load user: ${error.message}`
  } else {
    message = `Could not load user: ${String(error)}`
  }
}

Start with one function.

Install massaman, import what you need, and keep the rest out of your bundle.