functype 0.14.7 → 0.16.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
@@ -68,50 +68,11 @@ For detailed optimization strategies, see the [Bundle Optimization Guide](docs/B
68
68
 
69
69
  ### Option
70
70
 
71
- ```typescript
72
- import { Option, Some, None } from "functype"
73
-
74
- // Create options
75
- const value = Option("hello") // Some("hello")
76
- const empty = Option(null) // None
77
- const explicit = Some(42) // Some(42)
78
-
79
- // Transform values
80
- const length = value.map((s) => s.length) // Some(5)
81
- const nothing = empty.map((s) => s.length) // None
82
-
83
- // Handle default values
84
- const result = value.getOrElse("world") // "hello"
85
- const fallback = empty.getOrElse("world") // "world"
86
-
87
- // Conditionally filter
88
- const filtered = value.filter((s) => s.length > 10) // None
89
- ```
71
+ {@includeCode test/docs/documentation-examples.spec.ts#readme-option-basic}
90
72
 
91
73
  ### Either
92
74
 
93
- ```typescript
94
- import { Either, Right, Left } from "functype"
95
-
96
- // Success case
97
- const success = Right<string, number>(42)
98
- // Error case
99
- const failure = Left<string, number>("error")
100
-
101
- // Transform values (map only applies to Right)
102
- const doubled = success.map((x) => x * 2) // Right(84)
103
- const stillError = failure.map((x) => x * 2) // Left("error")
104
-
105
- // Handle errors
106
- const value = success.getOrElse(0) // 42
107
- const fallback = failure.getOrElse(0) // 0
108
-
109
- // Pattern matching with fold
110
- const result = success.fold(
111
- (err) => `Error: ${err}`,
112
- (val) => `Success: ${val}`,
113
- ) // "Success: 42"
114
- ```
75
+ {@includeCode test/docs/documentation-examples.spec.ts#readme-either-basic}
115
76
 
116
77
  ### List
117
78