{"id":49833035,"url":"https://github.com/zrosenbauer/massaman","last_synced_at":"2026-05-19T03:01:13.501Z","repository":{"id":357654321,"uuid":"1237173804","full_name":"zrosenbauer/massaman","owner":"zrosenbauer","description":"Functional programming utilities for TypeScript. Result types, pattern matching, async pipelines.","archived":false,"fork":false,"pushed_at":"2026-05-15T22:03:20.000Z","size":1784,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-05-16T00:40:31.638Z","etag":null,"topics":["es-toolkit","functional-programming","pattern-matching","result-type","ts-pattern","typescript"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/massaman","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zrosenbauer.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":"AGENTS.md","dco":null,"cla":null},"funding":{"github":"zrosenbauer"}},"created_at":"2026-05-13T00:20:14.000Z","updated_at":"2026-05-15T22:03:23.000Z","dependencies_parsed_at":null,"dependency_job_id":"160ab5c6-b131-4b7a-8d93-d86144884a9e","html_url":"https://github.com/zrosenbauer/massaman","commit_stats":null,"previous_names":["zrosenbauer/massaman"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/zrosenbauer/massaman","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zrosenbauer%2Fmassaman","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zrosenbauer%2Fmassaman/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zrosenbauer%2Fmassaman/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zrosenbauer%2Fmassaman/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zrosenbauer","download_url":"https://codeload.github.com/zrosenbauer/massaman/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zrosenbauer%2Fmassaman/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33124143,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-16T18:38:32.183Z","status":"ssl_error","status_checked_at":"2026-05-16T18:38:29.903Z","response_time":115,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["es-toolkit","functional-programming","pattern-matching","result-type","ts-pattern","typescript"],"created_at":"2026-05-13T22:03:10.949Z","updated_at":"2026-05-17T01:01:46.430Z","avatar_url":"https://github.com/zrosenbauer.png","language":"TypeScript","funding_links":["https://github.com/sponsors/zrosenbauer"],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n  \u003cimg src=\"https://raw.githubusercontent.com/zrosenbauer/massaman/main/.github/assets/banner.png\" alt=\"massaman\" width=\"100%\" /\u003e\n  \u003cp\u003e\u003cstrong\u003eFunctional programming utilities for TypeScript. Result types, pattern matching, async pipelines. Fully typed.\u003c/strong\u003e\u003c/p\u003e\n\n\u003ca href=\"https://github.com/zrosenbauer/massaman/actions/workflows/ci.yml\"\u003e\u003cimg src=\"https://github.com/zrosenbauer/massaman/actions/workflows/ci.yml/badge.svg?branch=main\" alt=\"CI\" /\u003e\u003c/a\u003e\n\u003ca href=\"https://www.npmjs.com/package/massaman\"\u003e\u003cimg src=\"https://img.shields.io/npm/v/massaman\" alt=\"npm version\" /\u003e\u003c/a\u003e\n\u003ca href=\"https://github.com/zrosenbauer/massaman/blob/main/LICENSE\"\u003e\u003cimg src=\"https://img.shields.io/github/license/zrosenbauer/massaman\" alt=\"License\" /\u003e\u003c/a\u003e\n\n\u003c/div\u003e\n\n## Features\n\n- Rust's `match` in TypeScript: exhaustive pattern matching via re-exported [ts-pattern](https://github.com/gvergnaud/ts-pattern).\n- Rust's `Result` in TypeScript: compose fallible operations without throws (`attempt`, `attemptAsync`, `ok`, `err`, `isOk`, `unwrap`).\n- Functional programming, fully typed: `flow`, `flowAsync`, `tap`, `when`, `ifElse`, and point-free combinators with end-to-end inference.\n- The missing pieces around [es-toolkit](https://es-toolkit.dev): variadic-narrowing predicates, async composition, and consistent error normalization on top of the array/object/string/math utilities you already love.\n- Tree-shakeable: 12 focused subpath exports, ESM-only, `sideEffects: false`. Import only what you use.\n\n## Install\n\n```bash\nnpm install massaman\n```\n\n## Usage\n\n### From ts-pattern\n\nThe `pattern` subpath is a transparent re-export of [ts-pattern](https://github.com/gvergnaud/ts-pattern). Exhaustive matching with full TypeScript inference.\n\n```ts\nimport { match, P } from 'massaman/pattern'\n\nconst status = match(action)\n  .with({ type: 'load' }, () =\u003e 'loading')\n  .with({ type: 'success' }, () =\u003e 'done')\n  .with({ type: 'error', msg: P.string }, ({ msg }) =\u003e `failed: ${msg}`)\n  .exhaustive()\n```\n\n### From es-toolkit\n\nMost of the surface (`array`, `object`, `string`, `function`, `math`) is a transparent re-export of [es-toolkit](https://es-toolkit.dev). Same names, same behavior, same docs.\n\n```ts\nimport { chunk, groupBy } from 'massaman'\n\nchunk([1, 2, 3, 4, 5], 2)\n// [[1, 2], [3, 4], [5]]\n\ngroupBy(['apple', 'avocado', 'banana', 'blueberry'], (s) =\u003e s[0])\n// { a: ['apple', 'avocado'], b: ['banana', 'blueberry'] }\n```\n\n### Custom: Result and async composition\n\nBuilt on top of those re-exports, `massaman/control` adds Result-style error handling that never throws across a boundary.\n\n```ts\nimport { attemptAsync, isOk } from 'massaman/control'\n\nconst result = await attemptAsync(() =\u003e fetch('/api/user').then((r) =\u003e r.json()))\n\nif (isOk(result)) {\n  console.log(result.value)\n} else {\n  console.error(result.error.message)\n}\n```\n\n## Why?\n\nTwo Rust patterns I keep wanting in TypeScript: `match` for exhaustive branching, and `Result` for errors that compose without throws.\n\nIn Rust:\n\n```rust\nmatch action {\n    Action::Load =\u003e \"loading\",\n    Action::Success =\u003e \"done\",\n    Action::Error(msg) =\u003e \u0026format!(\"failed: {}\", msg),\n}\n\nlet parsed: Result\u003cUser, Error\u003e = serde_json::from_str(raw);\nmatch parsed {\n    Ok(user) =\u003e println!(\"got: {}\", user.name),\n    Err(err) =\u003e eprintln!(\"failed: {}\", err),\n}\n```\n\nThe equivalent in TypeScript using `massaman`:\n\n```ts\nimport { match, P } from 'massaman/pattern'\nimport { attempt, isOk } from 'massaman/control'\n\nmatch(action)\n  .with({ type: 'load' }, () =\u003e 'loading')\n  .with({ type: 'success' }, () =\u003e 'done')\n  .with({ type: 'error', msg: P.string }, ({ msg }) =\u003e `failed: ${msg}`)\n  .exhaustive()\n\nconst parsed = attempt(() =\u003e JSON.parse(raw) as User)\nif (isOk(parsed)) {\n  console.log(`got: ${parsed.value.name}`)\n} else {\n  console.error(`failed: ${parsed.error.message}`)\n}\n```\n\n`massaman` brings both patterns to TypeScript, layered over [es-toolkit](https://es-toolkit.dev) and [ts-pattern](https://github.com/gvergnaud/ts-pattern), plus a thin set of utilities filling the gaps: async-aware composition, variadic-narrowing predicates, and consistent error normalization.\n\nMore on the philosophy at [zrosenbauer.com/gui/blog](https://zrosenbauer.com/gui/blog).\n\n## Contributing\n\nSee [CONTRIBUTING.md](https://github.com/zrosenbauer/massaman/blob/main/CONTRIBUTING.md) for development setup, conventions, and PR process.\n\n## License\n\n[MIT](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzrosenbauer%2Fmassaman","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzrosenbauer%2Fmassaman","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzrosenbauer%2Fmassaman/lists"}