functype 0.15.0 → 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 +2 -41
- package/README.processed.md +867 -0
- package/dist/{Either-DwiehtBQ.d.ts → Either-C-P6QnvK.d.ts} +1 -1
- package/dist/branded/index.d.ts +12 -5
- package/dist/branded/index.mjs +1 -1
- package/dist/chunk-OR6V4TCO.mjs +2 -0
- package/dist/chunk-OR6V4TCO.mjs.map +1 -0
- package/dist/chunk-ZRLVS2S5.mjs +45 -0
- package/dist/chunk-ZRLVS2S5.mjs.map +1 -0
- package/dist/do/index.d.ts +2 -2
- package/dist/do/index.mjs +1 -1
- package/dist/either/index.d.ts +1 -1
- package/dist/either/index.mjs +1 -1
- package/dist/fpromise/index.d.ts +1 -1
- package/dist/fpromise/index.mjs +1 -1
- package/dist/index.d.ts +55 -41
- package/dist/index.mjs +1 -1
- package/dist/list/index.d.ts +1 -1
- package/dist/list/index.mjs +1 -1
- package/dist/map/index.d.ts +1 -1
- package/dist/map/index.mjs +1 -1
- package/dist/option/index.d.ts +1 -1
- package/dist/option/index.mjs +1 -1
- package/dist/set/index.d.ts +1 -1
- package/dist/set/index.mjs +1 -1
- package/dist/try/index.d.ts +1 -1
- package/dist/try/index.mjs +1 -1
- package/package.json +19 -16
- package/dist/chunk-RUKG3LN7.mjs +0 -43
- package/dist/chunk-RUKG3LN7.mjs.map +0 -1
- package/dist/chunk-YBBRJTHY.mjs +0 -2
- package/dist/chunk-YBBRJTHY.mjs.map +0 -1
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
|
-
|
|
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
|
-
|
|
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
|
|