9
9
Takes two functions and an ` Either ` value, if the value is a ` Left ` the inner value is applied to the `onLeft function,
10
10
if the value is a ` Right ` the inner value is applied to the ` onRight ` function.
11
11
12
- @example
12
+ ## Example
13
+
13
14
``` ts
14
15
import { pipe , Either } from " effect"
15
16
@@ -24,8 +25,9 @@ assert.deepStrictEqual(
24
25
)
25
26
```
26
27
27
- @category pattern matching
28
- @since 2.0.0
28
+ ## Since
29
+
30
+ 2.0.0
29
31
30
32
## Call Signature
31
33
@@ -34,24 +36,6 @@ assert.deepStrictEqual(
34
36
Takes two functions and an ` Either ` value, if the value is a ` Left ` the inner value is applied to the `onLeft function,
35
37
if the value is a ` Right ` the inner value is applied to the ` onRight ` function.
36
38
37
- @example
38
- ``` ts
39
- import { pipe , Either } from " effect"
40
-
41
- const onLeft = (strings : ReadonlyArray <string >): string => ` strings: ${strings .join (' , ' )} `
42
-
43
- const onRight = (value : number ): string => ` Ok: ${value } `
44
-
45
- assert .deepStrictEqual (pipe (Either .right (1 ), Either .match ({ onLeft , onRight })), ' Ok: 1' )
46
- assert .deepStrictEqual (
47
- pipe (Either .left ([' string 1' , ' string 2' ]), Either .match ({ onLeft , onRight })),
48
- ' strings: string 1, string 2'
49
- )
50
- ```
51
-
52
- @category pattern matching
53
- @since 2.0.0
54
-
55
39
### Type Parameters
56
40
57
41
• ** L**
@@ -88,14 +72,22 @@ assert.deepStrictEqual(
88
72
89
73
` B ` \| ` C `
90
74
91
- ## Call Signature
75
+ ### Examples
92
76
93
- > ** match** \< ` R ` , ` L ` , ` B ` , ` C ` \> (` self ` , ` options ` ): ` B ` \| ` C `
77
+ ``` ts
78
+ import { pipe , Either } from " effect"
94
79
95
- Takes two functions and an ` Either ` value, if the value is a ` Left ` the inner value is applied to the `onLeft function,
96
- if the value is a ` Right ` the inner value is applied to the ` onRight ` function.
80
+ const onLeft = (strings : ReadonlyArray <string >): string => ` strings: ${strings .join (' , ' )} `
81
+
82
+ const onRight = (value : number ): string => ` Ok: ${value } `
83
+
84
+ assert .deepStrictEqual (pipe (Either .right (1 ), Either .match ({ onLeft , onRight })), ' Ok: 1' )
85
+ assert .deepStrictEqual (
86
+ pipe (Either .left ([' string 1' , ' string 2' ]), Either .match ({ onLeft , onRight })),
87
+ ' strings: string 1, string 2'
88
+ )
89
+ ```
97
90
98
- @example
99
91
``` ts
100
92
import { pipe , Either } from " effect"
101
93
@@ -110,8 +102,20 @@ assert.deepStrictEqual(
110
102
)
111
103
```
112
104
113
- @category pattern matching
114
- @since 2.0.0
105
+ ### Since
106
+
107
+ 2.0.0
108
+
109
+ ### Since
110
+
111
+ 2.0.0
112
+
113
+ ## Call Signature
114
+
115
+ > ** match** \< ` R ` , ` L ` , ` B ` , ` C ` \> (` self ` , ` options ` ): ` B ` \| ` C `
116
+
117
+ Takes two functions and an ` Either ` value, if the value is a ` Left ` the inner value is applied to the `onLeft function,
118
+ if the value is a ` Right ` the inner value is applied to the ` onRight ` function.
115
119
116
120
### Type Parameters
117
121
@@ -142,3 +146,41 @@ assert.deepStrictEqual(
142
146
### Returns
143
147
144
148
` B ` \| ` C `
149
+
150
+ ### Examples
151
+
152
+ ``` ts
153
+ import { pipe , Either } from " effect"
154
+
155
+ const onLeft = (strings : ReadonlyArray <string >): string => ` strings: ${strings .join (' , ' )} `
156
+
157
+ const onRight = (value : number ): string => ` Ok: ${value } `
158
+
159
+ assert .deepStrictEqual (pipe (Either .right (1 ), Either .match ({ onLeft , onRight })), ' Ok: 1' )
160
+ assert .deepStrictEqual (
161
+ pipe (Either .left ([' string 1' , ' string 2' ]), Either .match ({ onLeft , onRight })),
162
+ ' strings: string 1, string 2'
163
+ )
164
+ ```
165
+
166
+ ``` ts
167
+ import { pipe , Either } from " effect"
168
+
169
+ const onLeft = (strings : ReadonlyArray <string >): string => ` strings: ${strings .join (' , ' )} `
170
+
171
+ const onRight = (value : number ): string => ` Ok: ${value } `
172
+
173
+ assert .deepStrictEqual (pipe (Either .right (1 ), Either .match ({ onLeft , onRight })), ' Ok: 1' )
174
+ assert .deepStrictEqual (
175
+ pipe (Either .left ([' string 1' , ' string 2' ]), Either .match ({ onLeft , onRight })),
176
+ ' strings: string 1, string 2'
177
+ )
178
+ ```
179
+
180
+ ### Since
181
+
182
+ 2.0.0
183
+
184
+ ### Since
185
+
186
+ 2.0.0
0 commit comments