t-tasks 1.2.0 → 2.0.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/dist/either.d.ts DELETED
@@ -1,626 +0,0 @@
1
- /**
2
- * Right (correct) value of type R
3
- *
4
- * Either data type specialization representing a correct value
5
- *
6
- * @template R underlying value type
7
- * @template L underlying error type (needed for type merging, in fact alwas considered to be never)
8
- */
9
- export interface Right<R, L> {
10
- readonly right: R;
11
- /**
12
- * Either peeker function
13
- *
14
- * Applied to 'right value' returns self invoking op(value) in process
15
- * Applied to 'left error' returns self without invoking callback
16
- *
17
- * @param op function to be invoked with underlying value
18
- * @returns self
19
- */
20
- tap(op: (value: R) => void): this;
21
- /**
22
- * Either fallback peeker function
23
- *
24
- * Applied to 'right value' returns self without invoking callback
25
- * Applied to 'left error' returns self invoking op(error) in process
26
- *
27
- * @param op function to be invoked with underlying error
28
- * @returns self
29
- */
30
- orTap(op: (error: L) => void): this;
31
- /**
32
- * Either pattern matching peeker function
33
- *
34
- * Applied to 'right value' returns self invoking op.right(value) in process
35
- * Applied to 'left error' returns self invoking op.left(error) in process
36
- *
37
- * @param op.right function to be invoked with underlying value in case of 'right'
38
- * @param op.left function to be invoked with underlying error in case of 'left'
39
- * @returns self
40
- */
41
- matchTap(op: {
42
- right: (value: R) => void;
43
- left: (error: L) => void;
44
- }): this;
45
- /**
46
- * Either transformer function
47
- *
48
- * Applied to 'right value' returns 'right op(value)'
49
- * Applied to 'left error' returns self without invoking transformer
50
- *
51
- * @template R2 transformer function's return type
52
- * @param op transformer to be invoked with underlying value
53
- * @returns 'right op(value)' or 'left error'
54
- */
55
- map<R2>(this: Right<R, L>, op: (value: R) => R2): Right<R2, never>;
56
- map<R2>(this: Either<R, L>, op: (value: R) => R2): Either<R2, L>;
57
- /**
58
- * Either fallback transformer function
59
- *
60
- * Applied to 'right value' returns self without invoking transformer
61
- * Applied to 'left error' returns 'right op(error)'
62
- *
63
- * @param op transformer to be invoked with underlying error
64
- * @returns 'right value' or 'right op(error)'
65
- */
66
- orMap<R2>(this: Right<R, L>, op: (error: L) => R2): Right<R, never>;
67
- orMap<R2>(this: Either<R, L>, op: (error: L) => R2): Right<R | R2, never>;
68
- /**
69
- * Either pattern matching transformer function
70
- *
71
- * Applied to 'right value' returns 'right op.right(value)'
72
- * Applied to 'left error' returns 'right op.left(error)'
73
- *
74
- * @template R2 right transformer function's return type
75
- * @template R3 left transformer function's return type
76
- * @param op.right transformer to be invoked with underlying value in case of 'right'
77
- * @param op.left transformer to be invoked with underlying error in case of 'left'
78
- * @returns 'right op.right(value)' or 'right op.left(error)'
79
- */
80
- matchMap<R2, R3 = R2>(this: Right<R, L>, op: {
81
- right: (value: R) => R2;
82
- left: (error: L) => R3;
83
- }): Right<R2, never>;
84
- matchMap<R2, R3 = R2>(this: Either<R, L>, op: {
85
- right: (value: R) => R2;
86
- left: (error: L) => R3;
87
- }): Right<R2 | R3, never>;
88
- /**
89
- * Either composition function
90
- *
91
- * Applied to 'right value' returns 'op(value)'
92
- * Applied to 'left error' returns self without invoking composition function
93
- *
94
- * @template R2 transformer function result's underlying value type
95
- * @template L2 transformer function result's underlying error type
96
- * @param op transformer to be invoked with underlying value
97
- * @returns 'op(value)' or 'left error'
98
- */
99
- chain<R2, L2>(this: Right<R, L>, op: (value: R) => Right<R2, L2>): Right<R2, never>;
100
- chain<R2, L2>(this: Right<R, L>, op: (value: R) => Left<R2, L2>): Left<never, L2>;
101
- chain<R2, L2>(this: Right<R, L>, op: (value: R) => Either<R2, L2>): Either<R2, L2>;
102
- chain<R2, L2>(this: Either<R, L>, op: (value: R) => Right<R2, L2>): Either<R2, L>;
103
- chain<R2, L2>(this: Either<R, L>, op: (value: R) => Left<R2, L2>): Left<never, L | L2>;
104
- chain<R2, L2>(this: Either<R, L>, op: (value: R) => Either<R2, L2>): Either<R2, L | L2>;
105
- /**
106
- * Either composition function
107
- *
108
- * Applied to 'right value' returns self without invoking composition function
109
- * Applied to 'left error' returns 'op(error)'
110
- *
111
- * @template R2 transformer function result's underlying value type
112
- * @template L2 transformer function result's underlying error type
113
- * @param op transformer to be invoked with underlying value
114
- * @returns 'right value' or 'op(error)'
115
- */
116
- orChain<R2, L2>(this: Right<R, L>, op: (error: L) => Right<R2, L2>): Right<R, never>;
117
- orChain<R2, L2>(this: Right<R, L>, op: (error: L) => Left<R2, L2>): Right<R, never>;
118
- orChain<R2, L2>(this: Right<R, L>, op: (error: L) => Either<R2, L2>): Right<R, never>;
119
- orChain<R2, L2>(this: Either<R, L>, op: (error: L) => Right<R2, L2>): Right<R | R2, never>;
120
- orChain<R2, L2>(this: Either<R, L>, op: (error: L) => Left<R2, L2>): Either<R, L2>;
121
- orChain<R2, L2>(this: Either<R, L>, op: (error: L) => Either<R2, L2>): Either<R | R2, L2>;
122
- /**
123
- * Either pattern matching composition function
124
- *
125
- * Applied to 'right value' returns 'op.right(value)'
126
- * Applied to 'left error' returns 'op.left(error)'
127
- *
128
- * @template R2 right transformer function result's underlying value type
129
- * @template L2 right transformer function result's underlying error type
130
- * @template R3 left transformer function result's underlying value type
131
- * @template L3 left transformer function result's underlying error type
132
- * @param op.right transformer to be invoked with underlying value in case of 'right'
133
- * @param op.left transformer to be invoked with underlying error in case of 'left'
134
- * @returns 'op(value)' or 'op(error)'
135
- */
136
- matchChain<R2, L2, R3 = R2, L3 = L2>(this: Right<R, L>, op: {
137
- right: (value: R) => Right<R2, L2>;
138
- left: (error: L) => Right<R3, L3>;
139
- }): Right<R2, never>;
140
- matchChain<R2, L2, R3 = R2, L3 = L2>(this: Right<R, L>, op: {
141
- right: (value: R) => Left<R2, L2>;
142
- left: (error: L) => Right<R3, L3>;
143
- }): Left<never, L2>;
144
- matchChain<R2, L2, R3 = R2, L3 = L2>(this: Right<R, L>, op: {
145
- right: (value: R) => Right<R2, L2>;
146
- left: (error: L) => Left<R3, L3>;
147
- }): Right<R2, never>;
148
- matchChain<R2, L2, R3 = R2, L3 = L2>(this: Right<R, L>, op: {
149
- right: (value: R) => Left<R2, L2>;
150
- left: (error: L) => Left<R3, L3>;
151
- }): Left<never, L2>;
152
- matchChain<R2, L2, R3 = R2, L3 = L2>(this: Right<R, L>, op: {
153
- right: (value: R) => Either<R2, L2>;
154
- left: (error: L) => Right<R3, L3>;
155
- }): Either<R2, L2>;
156
- matchChain<R2, L2, R3 = R2, L3 = L2>(this: Right<R, L>, op: {
157
- right: (value: R) => Either<R2, L2>;
158
- left: (error: L) => Left<R3, L3>;
159
- }): Either<R2, L2>;
160
- matchChain<R2, L2, R3 = R2, L3 = L2>(this: Right<R, L>, op: {
161
- right: (value: R) => Right<R2, L2>;
162
- left: (error: L) => Either<R3, L3>;
163
- }): Right<R2, never>;
164
- matchChain<R2, L2, R3 = R2, L3 = L2>(this: Right<R, L>, op: {
165
- right: (value: R) => Left<R2, L2>;
166
- left: (error: L) => Either<R3, L3>;
167
- }): Left<never, L2>;
168
- matchChain<R2, L2, R3 = R2, L3 = L2>(this: Right<R, L>, op: {
169
- right: (value: R) => Either<R2, L2>;
170
- left: (error: L) => Either<R3, L3>;
171
- }): Either<R2, L2>;
172
- matchChain<R2, L2, R3 = R2, L3 = L2>(this: Either<R, L>, op: {
173
- right: (value: R) => Right<R2, L2>;
174
- left: (error: L) => Right<R3, L3>;
175
- }): Right<R2 | R3, never>;
176
- matchChain<R2, L2, R3 = R2, L3 = L2>(this: Either<R, L>, op: {
177
- right: (value: R) => Left<R2, L2>;
178
- left: (error: L) => Right<R3, L3>;
179
- }): Either<R3, L2>;
180
- matchChain<R2, L2, R3 = R2, L3 = L2>(this: Either<R, L>, op: {
181
- right: (value: R) => Right<R2, L2>;
182
- left: (error: L) => Left<R3, L3>;
183
- }): Either<R2, L3>;
184
- matchChain<R2, L2, R3 = R2, L3 = L2>(this: Either<R, L>, op: {
185
- right: (value: R) => Left<R2, L2>;
186
- left: (error: L) => Left<R3, L3>;
187
- }): Left<never, L2 | L3>;
188
- matchChain<R2, L2, R3 = R2, L3 = L2>(this: Either<R, L>, op: {
189
- right: (value: R) => Either<R2, L2>;
190
- left: (error: L) => Right<R3, L3>;
191
- }): Either<R2 | R3, L2>;
192
- matchChain<R2, L2, R3 = R2, L3 = L2>(this: Either<R, L>, op: {
193
- right: (value: R) => Either<R2, L2>;
194
- left: (error: L) => Left<R3, L3>;
195
- }): Either<R2, L2 | L3>;
196
- matchChain<R2, L2, R3 = R2, L3 = L2>(this: Either<R, L>, op: {
197
- right: (value: R) => Right<R2, L2>;
198
- left: (error: L) => Either<R3, L3>;
199
- }): Either<R2 | R3, L3>;
200
- matchChain<R2, L2, R3 = R2, L3 = L2>(this: Either<R, L>, op: {
201
- right: (value: R) => Left<R2, L2>;
202
- left: (error: L) => Either<R3, L3>;
203
- }): Either<R3, L2 | L3>;
204
- matchChain<R2, L2, R3 = R2, L3 = L2>(this: Either<R, L>, op: {
205
- right: (value: R) => Either<R2, L2>;
206
- left: (error: L) => Either<R3, L3>;
207
- }): Either<R2 | R3, L2 | L3>;
208
- /**
209
- * Either type guard for 'right'
210
- *
211
- * @returns 'true' in case this is 'right value' (and resolves type to be 'right')
212
- *
213
- * @example
214
- * ```typescript
215
- * if (either.isRight()) {
216
- * console.log(either.right)
217
- * }
218
- * ```
219
- */
220
- isRight(): this is Right<R, L>;
221
- /**
222
- * Either type guard for 'left'
223
- *
224
- * @returns 'true' in case this is 'left error' (and resolves type to be 'left')
225
- *
226
- * @example
227
- * ```typescript
228
- * if (either.isLeft()) {
229
- * console.error(either.left)
230
- * }
231
- * ```
232
- */
233
- isLeft(): this is Left<R, L>;
234
- /**
235
- * Wrap Maybe to singleton generator
236
- *
237
- * Userful in order to avoid ambiguous yied types
238
- *
239
- * @returns generator of Maybe wrapping this
240
- */
241
- generator: EitherGeneratorFunction<[], R, Right<R, L>, R>;
242
- }
243
- /**
244
- * Left (erroneous) value of type L
245
- *
246
- * Either data type specialization representing an erroneous value
247
- *
248
- * @remplate R underlying value type (needed for type merging, in fact alwas considered to be never)
249
- * @template L underlying error type
250
- */
251
- export interface Left<R, L> {
252
- readonly left: L;
253
- /**
254
- * Either peeker function
255
- *
256
- * Applied to 'right value' returns self invoking op(value) in process
257
- * Applied to 'left error' returns self without invoking callback
258
- *
259
- * @param op function to be invoked with underlying value
260
- * @returns self
261
- */
262
- tap(op: (value: R) => void): this;
263
- /**
264
- * Either fallback peeker function
265
- *
266
- * Applied to 'right value' returns self without invoking callback
267
- * Applied to 'left error' returns self invoking op(error) in process
268
- *
269
- * @param op function to be invoked with underlying value
270
- * @returns self
271
- */
272
- orTap(op: (error: L) => void): this;
273
- /**
274
- * Either pattern matching peeker function
275
- *
276
- * Applied to 'right value' returns self invoking op.right(value) in process
277
- * Applied to 'left error' returns self invoking op.left(error) in process
278
- *
279
- * @param op.right function to be invoked with underlying value in case of 'right'
280
- * @param op.left function to be invoked with underlying error in case of 'left'
281
- * @returns self
282
- */
283
- matchTap(op: {
284
- right: (value: R) => void;
285
- left: (error: L) => void;
286
- }): this;
287
- /**
288
- * Either transformer function
289
- *
290
- * Applied to 'right value' returns 'right op(value)'
291
- * Applied to 'left error' returns self without invoking transformer
292
- *
293
- * @template R2 transformer function's return type
294
- * @param op transformer to be invoked with underlying value
295
- * @returns 'right op(value)' or 'left error'
296
- */
297
- map<R2>(this: Left<R, L>, op: (value: R) => R2): Left<never, L>;
298
- map<R2>(this: Either<R, L>, op: (value: R) => R2): Either<R2, L>;
299
- /**
300
- * Either fallback transformer function
301
- *
302
- * Applied to 'right value' returns self without invoking transformer
303
- * Applied to 'left error' returns 'right op(error)'
304
- *
305
- * @param op transformer to be invoked with underlying error
306
- * @returns 'right value' or 'right op(error)'
307
- */
308
- orMap<R2>(this: Left<R, L>, op: (error: L) => R2): Right<R2, never>;
309
- orMap<R2>(this: Either<R, L>, op: (error: L) => R2): Right<R | R2, never>;
310
- /**
311
- * Either pattern matching transformer function
312
- *
313
- * Applied to 'right value' returns 'right op.right(value)'
314
- * Applied to 'left error' returns 'right op.left(error)'
315
- *
316
- * @template R2 right transformer function's return type
317
- * @template R3 left transformer function's return type
318
- * @param op.right transformer to be invoked with underlying value in case of 'right'
319
- * @param op.left transformer to be invoked with underlying error in case of 'left'
320
- * @returns 'right op.right(value)' or 'right op.left(error)'
321
- */
322
- matchMap<R2, R3 = R2>(this: Left<R, L>, op: {
323
- right: (value: R) => R2;
324
- left: (error: L) => R3;
325
- }): Right<R3, never>;
326
- matchMap<R2, R3 = R2>(this: Either<R, L>, op: {
327
- right: (value: R) => R2;
328
- left: (error: L) => R3;
329
- }): Right<R2 | R3, never>;
330
- /**
331
- * Either composition function
332
- *
333
- * Applied to 'right value' returns 'op(value)'
334
- * Applied to 'left error' returns self without invoking composition function
335
- *
336
- * @template R2 transformer function result's underlying value type
337
- * @template L2 transformer function result's underlying error type
338
- * @param op transformer to be invoked with underlying value
339
- * @returns 'op(value)' or 'left error'
340
- */
341
- chain<R2, L2>(this: Left<R, L>, op: (value: R) => Right<R2, L2>): Left<never, L>;
342
- chain<R2, L2>(this: Left<R, L>, op: (value: R) => Left<R2, L2>): Left<never, L>;
343
- chain<R2, L2>(this: Left<R, L>, op: (value: R) => Either<R2, L2>): Left<never, L>;
344
- chain<R2, L2>(this: Either<R, L>, op: (value: R) => Right<R2, L2>): Either<R2, L>;
345
- chain<R2, L2>(this: Either<R, L>, op: (value: R) => Left<R2, L2>): Left<never, L | L2>;
346
- chain<R2, L2>(this: Either<R, L>, op: (value: R) => Either<R2, L2>): Either<R2, L | L2>;
347
- /**
348
- * Either fallback composition function
349
- *
350
- * Applied to 'right value' returns self without invoking composition function
351
- * Applied to 'left error' returns 'op(error)'
352
- *
353
- * @template R2 transformer function result's underlying value type
354
- * @template L2 transformer function result's underlying error type
355
- * @param op transformer to be invoked with underlying value
356
- * @returns 'right value' or 'op(error)'
357
- */
358
- orChain<R2, L2>(this: Left<R, L>, op: (error: L) => Right<R2, L2>): Right<R2, never>;
359
- orChain<R2, L2>(this: Left<R, L>, op: (error: L) => Left<R2, L2>): Left<never, L2>;
360
- orChain<R2, L2>(this: Left<R, L>, op: (error: L) => Either<R2, L2>): Either<R2, L2>;
361
- orChain<R2, L2>(this: Either<R, L>, op: (error: L) => Right<R2, L2>): Right<R | R2, never>;
362
- orChain<R2, L2>(this: Either<R, L>, op: (error: L) => Left<R2, L2>): Either<R, L2>;
363
- orChain<R2, L2>(this: Either<R, L>, op: (error: L) => Either<R2, L2>): Either<R | R2, L2>;
364
- /**
365
- * Either pattern matching composition function
366
- *
367
- * Applied to 'right value' returns 'op.right(value)'
368
- * Applied to 'left error' returns 'op.left(error)'
369
- *
370
- * @template R2 right transformer function result's underlying value type
371
- * @template L2 right transformer function result's underlying error type
372
- * @template R3 left transformer function result's underlying value type
373
- * @template L3 left transformer function result's underlying error type
374
- * @param op.right transformer to be invoked with underlying value in case of 'right'
375
- * @param op.left transformer to be invoked with underlying error in case of 'left'
376
- * @returns 'op(value)' or 'op(error)'
377
- */
378
- matchChain<R2, L2, R3 = R2, L3 = L2>(this: Left<R, L>, op: {
379
- right: (value: R) => Right<R2, L2>;
380
- left: (error: L) => Right<R3, L3>;
381
- }): Right<R3, never>;
382
- matchChain<R2, L2, R3 = R2, L3 = L2>(this: Left<R, L>, op: {
383
- right: (value: R) => Left<R2, L2>;
384
- left: (error: L) => Right<R3, L3>;
385
- }): Right<R3, never>;
386
- matchChain<R2, L2, R3 = R2, L3 = L2>(this: Left<R, L>, op: {
387
- right: (value: R) => Right<R2, L2>;
388
- left: (error: L) => Left<R3, L3>;
389
- }): Left<never, L3>;
390
- matchChain<R2, L2, R3 = R2, L3 = L2>(this: Left<R, L>, op: {
391
- right: (value: R) => Left<R2, L2>;
392
- left: (error: L) => Left<R3, L3>;
393
- }): Left<never, L3>;
394
- matchChain<R2, L2, R3 = R2, L3 = L2>(this: Left<R, L>, op: {
395
- right: (value: R) => Either<R2, L2>;
396
- left: (error: L) => Right<R3, L3>;
397
- }): Right<R3, never>;
398
- matchChain<R2, L2, R3 = R2, L3 = L2>(this: Left<R, L>, op: {
399
- right: (value: R) => Either<R2, L2>;
400
- left: (error: L) => Left<R3, L3>;
401
- }): Left<never, L3>;
402
- matchChain<R2, L2, R3 = R2, L3 = L2>(this: Left<R, L>, op: {
403
- right: (value: R) => Right<R2, L2>;
404
- left: (error: L) => Either<R3, L3>;
405
- }): Either<R3, L3>;
406
- matchChain<R2, L2, R3 = R2, L3 = L2>(this: Left<R, L>, op: {
407
- right: (value: R) => Left<R2, L2>;
408
- left: (error: L) => Either<R3, L3>;
409
- }): Either<R3, L3>;
410
- matchChain<R2, L2, R3 = R2, L3 = L2>(this: Left<R, L>, op: {
411
- right: (value: R) => Either<R2, L2>;
412
- left: (error: L) => Either<R3, L3>;
413
- }): Either<R3, L3>;
414
- matchChain<R2, L2, R3 = R2, L3 = L2>(this: Either<R, L>, op: {
415
- right: (value: R) => Right<R2, L2>;
416
- left: (error: L) => Right<R3, L3>;
417
- }): Right<R2 | R3, never>;
418
- matchChain<R2, L2, R3 = R2, L3 = L2>(this: Either<R, L>, op: {
419
- right: (value: R) => Left<R2, L2>;
420
- left: (error: L) => Right<R3, L3>;
421
- }): Either<R3, L2>;
422
- matchChain<R2, L2, R3 = R2, L3 = L2>(this: Either<R, L>, op: {
423
- right: (value: R) => Right<R2, L2>;
424
- left: (error: L) => Left<R3, L3>;
425
- }): Either<R2, L3>;
426
- matchChain<R2, L2, R3 = R2, L3 = L2>(this: Either<R, L>, op: {
427
- right: (value: R) => Left<R2, L2>;
428
- left: (error: L) => Left<R3, L3>;
429
- }): Left<never, L2 | L3>;
430
- matchChain<R2, L2, R3 = R2, L3 = L2>(this: Either<R, L>, op: {
431
- right: (value: R) => Either<R2, L2>;
432
- left: (error: L) => Right<R3, L3>;
433
- }): Either<R2 | R3, L2>;
434
- matchChain<R2, L2, R3 = R2, L3 = L2>(this: Either<R, L>, op: {
435
- right: (value: R) => Either<R2, L2>;
436
- left: (error: L) => Left<R3, L3>;
437
- }): Either<R2, L2 | L3>;
438
- matchChain<R2, L2, R3 = R2, L3 = L2>(this: Either<R, L>, op: {
439
- right: (value: R) => Right<R2, L2>;
440
- left: (error: L) => Either<R3, L3>;
441
- }): Either<R2 | R3, L3>;
442
- matchChain<R2, L2, R3 = R2, L3 = L2>(this: Either<R, L>, op: {
443
- right: (value: R) => Left<R2, L2>;
444
- left: (error: L) => Either<R3, L3>;
445
- }): Either<R3, L2 | L3>;
446
- matchChain<R2, L2, R3 = R2, L3 = L2>(this: Either<R, L>, op: {
447
- right: (value: R) => Either<R2, L2>;
448
- left: (error: L) => Either<R3, L3>;
449
- }): Either<R2 | R3, L2 | L3>;
450
- /**
451
- * Either type guard for 'right'
452
- *
453
- * @returns 'true' in case this is 'right value' (and resolves type to be 'right')
454
- *
455
- * @example
456
- * ```typescript
457
- * if (either.isRight()) {
458
- * console.log(either.right)
459
- * }
460
- * ```
461
- */
462
- isRight(): this is Right<R, L>;
463
- /**
464
- * Either type guard for 'left'
465
- *
466
- * @returns 'true' in case this is 'left error' (and resolves type to be 'left')
467
- *
468
- * @example
469
- * ```typescript
470
- * if (either.isLeft()) {
471
- * console.error(either.left)
472
- * }
473
- * ```
474
- */
475
- isLeft(): this is Left<R, L>;
476
- /**
477
- * Wrap Maybe to singleton generator
478
- *
479
- * Userful in order to avoid ambiguous yied types
480
- *
481
- * @returns generator of Maybe wrapping this
482
- */
483
- generator: EitherGeneratorFunction<[], R, Left<R, L>, R>;
484
- }
485
- /**
486
- * Either data type: either Right value of type R or Left value of type L
487
- *
488
- * As per classic Either monad implementation can eithr contain a right (correct) value or a left (erroneous) value
489
- * Used throughout the library to represent the result of failable operations, namely failed tasks
490
- *
491
- * @template R underlying value type
492
- * @template L underlying error type
493
- */
494
- export type Either<R, L> = Right<R, L> | Left<R, L>;
495
- export declare namespace Right {
496
- /**
497
- * Standalone Right value extractor
498
- *
499
- * Userful for passing as a function to collection transformers
500
- *
501
- * @template R underlying value type
502
- * @template L underlying error type
503
- * @param right Right instance
504
- * @returns underlying value
505
- */
506
- function right<R, L>(right: Right<R, L>): R;
507
- }
508
- export declare namespace Left {
509
- /**
510
- * Standalone Left error extractor
511
- *
512
- * Userful for passing as a function to collection transformers
513
- *
514
- * @template R underlying value type
515
- * @template L underlying error type
516
- * @param left Left instance
517
- * @returns underlying error
518
- */
519
- function left<R, L>(left: Left<R, L>): L;
520
- }
521
- export type EitherGenerator<T, TT extends Either<T, any>, R> = Generator<TT, R, T>;
522
- export type EitherGeneratorFunction<A extends unknown[], T, TT extends Either<T, any>, R> = (...args: A) => EitherGenerator<T, TT, R>;
523
- export declare namespace Either {
524
- /**
525
- * Right monad constructor
526
- *
527
- * @template R underlying value type
528
- * @param value underlying value
529
- * @returns 'right value'
530
- */
531
- function right<R>(value: R): Right<R, never>;
532
- /**
533
- * Left monad constructor
534
- *
535
- * @template L underlying error type
536
- * @param error underlying error
537
- * @returns 'left error'
538
- */
539
- function left<L>(error: L): Left<never, L>;
540
- /**
541
- * Either constructor from optional value
542
- *
543
- * Resolves to 'left error' in case of undefined value and 'right value' otherwise
544
- *
545
- * @param value possibly undefined value
546
- * @param error error to use in case of undefined value
547
- * @returns either 'right value' or 'left error'
548
- */
549
- function fromOptional<L>(value: undefined, error: L): Left<never, L>;
550
- function fromOptional<R>(value: Exclude<R, undefined>, error: unknown): Right<R, never>;
551
- function fromOptional<R, L>(value: R | undefined, error: L): Either<R, L>;
552
- /**
553
- * Either constructor from optional or nullable value
554
- *
555
- * Resolves to 'left error' in case of undefined or null value and 'right value' otherwise
556
- *
557
- * @param value possibly undefined or nullable value
558
- * @param error error to use in case of undefined or nullable value
559
- * @returns either 'right value' or 'left error'
560
- */
561
- function fromNullable<L>(value: undefined, error: L): Left<never, L>;
562
- function fromNullable<L>(value: null, error: L): Left<never, L>;
563
- function fromNullable<R>(value: Exclude<R, null | undefined>, error: unknown): Right<R, never>;
564
- function fromNullable<R, L>(value: R | null | undefined, error: L): Either<R, L>;
565
- /**
566
- * Standalone type guard for 'right'
567
- *
568
- * Userful for passing as a predicate to collection transformers
569
- *
570
- * @template R underlying value type
571
- * @param either Either instance
572
- * @returns 'true' in case argument is 'right value' (and resolves type to be 'right')
573
- */
574
- function isRight<R, L>(either: Either<R, L>): either is Right<R, never>;
575
- /**
576
- * Standalone type guard for 'left'
577
- *
578
- * Userful for passing as a predicate to collection transformers
579
- *
580
- * @template R underlying value type
581
- * @param either Either instance
582
- * @returns 'true' in case argument is 'left error' (and resolves type to be 'left')
583
- */
584
- function isLeft<R, L>(either: Either<R, L>): either is Left<never, L>;
585
- /**
586
- * Standalone list predicate
587
- *
588
- * @param eithers a list of Either
589
- * @returns true in case every list element is Right
590
- */
591
- function everyRight<R, L>(eithers: Either<R, L>[]): eithers is Right<R, never>[];
592
- /**
593
- * Standalone list predicate
594
- *
595
- * @param eithers a list of Either
596
- * @returns true in case at least one list element is Right
597
- */
598
- function someRight<R, L>(eithers: Either<R, L>[]): boolean;
599
- /**
600
- * Standalone list predicate
601
- *
602
- * @param eithers a list of Either
603
- * @returns true in case every list element is Left
604
- */
605
- function everyLeft<R, L>(eithers: Either<R, L>[]): eithers is Left<never, L>[];
606
- /**
607
- * Standalone list predicate
608
- *
609
- * @param eithers a list of Either
610
- * @returns true in case at least one list element is Left
611
- */
612
- function someLeft<R, L>(eithers: Either<R, L>[]): boolean;
613
- /**
614
- * Create compound Either from generator function
615
- *
616
- * Applying yield to a Maybe within the generator function unwraps the Maybe and returns underlying value in case of success
617
- * However the convinient option for typescript is to use ```yield* maybe.generator()``` as othervise one may have to deal with union types
618
- *
619
- * @template TT yielded Maybe type
620
- * @template R returned underlying type
621
- * @param maybeGeneratorFunction Maybe generator function
622
- * @returns Just wrapping the result of generator function or Nothing
623
- * ```
624
- */
625
- function generate<T, TT extends Either<T, any>, R>(eitherGeneratorFunction: EitherGeneratorFunction<[], T, TT, R>): Either<R, any>;
626
- }
package/dist/index.d.ts DELETED
@@ -1,3 +0,0 @@
1
- export * from './maybe';
2
- export * from './either';
3
- export * from './task';