← ClaudeAtlas

functional-javascriptlisted

Use when applying functional design in plain JavaScript, without a type checker, including immutability, tagged unions, and Result-style error handling.
yutna/functional-design-skills · ★ 0 · AI & Automation · score 75
Install: claude install-skill yutna/functional-design-skills
# Functional JavaScript ## Overview JavaScript has first-class functions, closures, and object literals, which is everything the core skills need. What it lacks is a compiler to enforce the designs, so the enforcement moves to three places: constructor functions, freezing, and tests that assert exhaustiveness. Read the core skill for the rule; read this for how to express it. ## When to use - A project written in plain JavaScript, with no type checker - Node services, scripts, or browser code without TypeScript - Adding JSDoc types to an existing JavaScript codebase Not for: TypeScript projects, which have [functional-typescript](../functional-typescript/SKILL.md). ## Notation mapping | Neutral notation | JavaScript | | ------------------- | ----------------------------------------------- | | Record type | Frozen object literal | | Choice type | Object with a `tag` field | | Single-case wrapper | Frozen `{ tag, value }` | | `Result<T, E>` | `{ ok: true, value }` or `{ ok: false, error }` | | `Option<T>` | `undefined`, or a `Maybe` object | | `A -> B -> C` | Arrow function returning a function | | `>>` composition | `pipe` helper, or nested calls | | `Async<T>` | `Promise<T>` | | Exhaustive match | `switch` with a `default` that thr