diff --git a/.well-known/agent-skills/tsentials-errors/SKILL.md b/.well-known/agent-skills/tsentials-errors/SKILL.md index 85b51e7..42f1e56 100644 --- a/.well-known/agent-skills/tsentials-errors/SKILL.md +++ b/.well-known/agent-skills/tsentials-errors/SKILL.md @@ -174,7 +174,7 @@ function findUser(id: string): Result { ```typescript import { Result } from 'tsentials/result'; -import { Err } from 'tsentials/errors'; +import { Err, ErrorType } from 'tsentials/errors'; function divide(a: number, b: number): Result { if (b === 0) return Result.failure(Err.validation('Math.DivideByZero', 'Cannot divide by zero.')); diff --git a/AGENTS.md b/AGENTS.md index 05281aa..17c1954 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -418,7 +418,7 @@ Result.then(safeJsonParse(raw), data => validatePayload(data)); ```bash npm run build # tsc compile -npm test # vitest run (762 tests) +npm test # vitest run (1079 tests) npm run check # biome lint + format check npm run lint:fix # auto-fix lint ``` diff --git a/CLAUDE.md b/CLAUDE.md index 98c09d1..be5af73 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -330,7 +330,7 @@ toUnderscoreCamelCase('helloWorld') // "_helloWorld" - `"sideEffects": false` in package.json for full tree-shaking ## Testing -Vitest — `npm test` runs all 1075 tests across 33 test files. +Vitest — `npm test` runs all 1079 tests across 33 test files. Test files mirror src/ structure under `tests/`. ## Publishing diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 9a053e3..281e187 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -6,7 +6,7 @@ Thank you for your interest in contributing! ```bash git clone https://github.com/senrecep/tsentials.git -cd TypeScriptEssentials +cd tsentials npm install npm run build npm test diff --git a/README.md b/README.md index 1df3591..fe7107d 100644 --- a/README.md +++ b/README.md @@ -130,13 +130,14 @@ Result.ok(); ### Pipeline (sync) ```typescript -import { Result } from 'tsentials/result'; +import { Result, chain } from 'tsentials/result'; import { Err } from 'tsentials/errors'; -const price = Result.success(100) - |> Result.map(_, n => n * 1.2) - |> Result.ensure(_, n => n < 200, Err.validation('Price.TooHigh', 'Exceeds limit')) - |> Result.map(_, n => `$${n.toFixed(2)}`); +const price = chain(Result.success(100)) + .map(n => n * 1.2) + .ensure(n => n < 200, Err.validation('Price.TooHigh', 'Exceeds limit')) + .map(n => `$${n.toFixed(2)}`) + .unwrap(); // => { ok: true, value: "$120.00" } // Dynamic error from value @@ -786,12 +787,12 @@ const sure = asNonEmptyArray([1, 2]); // Some([1, 2]) Composable, type-safe equality and ordering. ```typescript -import { Eq, Ord } from 'tsentials/eq'; -import { sortBy, min, max, clamp } from 'tsentials/ord'; +import { Eq } from 'tsentials/eq'; +import { Ord, sortBy, min, max, clamp } from 'tsentials/ord'; -interface User { readonly id: number; readonly name: string; } +interface User { readonly id: number; readonly name: string; readonly age: number; } -const eqUser = Eq.struct({ id: Eq.number, name: Eq.string }); +const eqUser = Eq.struct({ id: Eq.number, name: Eq.string, age: Eq.number }); const byAge = Ord.contramap(Ord.number, (u: User) => u.age); const sorted = sortBy(users, byAge); diff --git a/package-lock.json b/package-lock.json index 3e35fb7..c4d01af 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "tsentials", - "version": "0.1.9", + "version": "0.1.10", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "tsentials", - "version": "0.1.9", + "version": "0.1.10", "license": "MIT", "devDependencies": { "@biomejs/biome": "^2.4.15", diff --git a/package.json b/package.json index 10c9495..128bd2d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "tsentials", - "version": "0.1.9", + "version": "0.1.10", "description": "Railway-oriented programming for TypeScript — Result, Maybe, Rule Engine, and DDD base classes with full async pipeline support", "type": "module", "main": "./dist/index.js",