ok-fp 0.2.1 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -8,14 +8,15 @@ OK-FP is a small, focused functional programming toolkit for TypeScript.
8
8
 
9
9
  It provides a minimal set of **typed effects**: composable, type-safe wrappers for optional values, errors, and async computations.
10
10
 
11
- ## Status
11
+ ## Effects
12
12
 
13
- OK-FP is pre-1.0.
14
-
15
- - ✅ Implemented: `Option`, `Either`, `Validation`, `Task`
16
- - 🚧 Planned before `v1.0.0`: `TaskEither`
17
-
18
- See: [ROADMAP.md](./ROADMAP.md)
13
+ | Effect | Description |
14
+ | ------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------- |
15
+ | [`Option<T>`](https://pwlmc.github.io/ok-fp/option) | A value that may or may not be present. Use instead of `null`/`undefined`. |
16
+ | [`Either<E, T>`](https://pwlmc.github.io/ok-fp/either) | A computation that succeeds with `T` or fails with a typed error `E`. Errors are explicit and must be handled. |
17
+ | [`Validation<E, T>`](https://pwlmc.github.io/ok-fp/validation) | Like `Either`, but accumulates **all** errors instead of stopping at the first one. Ideal for form and config validation. |
18
+ | [`Task<T>`](https://pwlmc.github.io/ok-fp/task) | A lazy async computation that always succeeds. Executes only when `.run()` is called - unlike Promises, which are eager. |
19
+ | [`TaskEither<E, T>`](https://pwlmc.github.io/ok-fp/task-either) | A lazy async computation that can succeed with `T` or fail with `E`. Combines `Task`'s laziness with `Either`'s typed errors. |
19
20
 
20
21
  ## Installation
21
22
 
@@ -33,7 +34,7 @@ npm install ok-fp
33
34
  This example shows a small pipeline using `Option`.
34
35
 
35
36
  ```ts
36
- import { type Option, some, none } from "ok-fp/option";
37
+ import { type Option, some, none } from "ok-fp";
37
38
 
38
39
  const parseNumber = (input: string): Option<number> => {
39
40
  const n = Number(input);
@@ -46,15 +47,15 @@ const positive = (n: number): Option<number> => (n > 0 ? some(n) : none());
46
47
 
47
48
  const compute = (input: string): Option<number> =>
48
49
  parseNumber(input)
49
- .flatMap(nonZero) // must not be 0
50
- .flatMap(positive) // must be > 0
51
- .map((n) => 1 / n) // reciprocal (no need for flatMap)
50
+ .flatMap(nonZero) // must not be 0
51
+ .flatMap(positive) // must be > 0
52
+ .map((n) => 1 / n) // reciprocal (no need for flatMap)
52
53
  .map((n) => n * 100); // scale
53
54
 
54
55
  // Usage (returns Option instances)
55
- compute("4"); // returns some(25)
56
- compute("0"); // returns none() (fails nonZero)
57
- compute("-3"); // returns none() (fails positive)
56
+ compute("4"); // returns some(25)
57
+ compute("0"); // returns none() (fails nonZero)
58
+ compute("-3"); // returns none() (fails positive)
58
59
  compute("abc"); // returns none() (fails parsing)
59
60
  ```
60
61