@@ -8,17 +8,19 @@ const eitherToTask = e =>
8
8
e . fold ( Task . rejected , Task . of )
9
9
10
10
11
- console . log (
12
- `eitherToTask(Right('nightingale')).fork(..., ...) : `
11
+ console . log ( `
12
+ eitherToTask(Right('nightingale'))
13
+ .fork(..., ...) : `
13
14
)
14
15
eitherToTask ( Right ( 'nightingale' ) )
15
16
. fork (
16
17
e => console . error ( 'Error: ' , e ) ,
17
18
res => console . log ( 'Result: ' , res )
18
19
)
19
20
20
- console . log (
21
- `eitherToTask(Left('errrr')).fork(..., ...) : `
21
+ console . log ( `
22
+ eitherToTask(Left('errrr'))
23
+ .fork(..., ...) : `
22
24
)
23
25
eitherToTask ( Left ( 'errrr' ) )
24
26
. fork (
@@ -44,12 +46,16 @@ const res2 = boxToEither(
44
46
)
45
47
46
48
// results should be the same!
47
- console . log (
48
- `boxToEither(Box(100)).map( x => x * 2 ) : ` ,
49
+ console . log ( `
50
+ boxToEither(Box(100))
51
+ .map( x => x * 2 ) :
52
+ ` ,
49
53
res1
50
54
)
51
- console . log (
52
- `boxToEither(Box(100).map( x => x * 2 )) : ` ,
55
+ console . log ( `
56
+ boxToEither(Box(100)
57
+ .map( x => x * 2 )) :
58
+ ` ,
53
59
res2
54
60
)
55
61
@@ -72,12 +78,14 @@ const res22 = boxToEitherBad(
72
78
)
73
79
74
80
// natural transformation law is violated!
75
- console . log (
76
- `boxToEitherBad(Box(100)).map( x => x * 2 ) : ` ,
81
+ console . log ( `
82
+ boxToEitherBad(Box(100))
83
+ .map( x => x * 2 ) : ` ,
77
84
res21
78
85
)
79
- console . log (
80
- `boxToEitherBad(Box(100).map( x => x * 2 )) : ` ,
86
+ console . log ( `
87
+ boxToEitherBad(Box(100)
88
+ .map( x => x * 2 )) : ` ,
81
89
res22
82
90
)
83
91
@@ -93,12 +101,14 @@ const res31 = first([1,2,3]).map( x => x + 1 )
93
101
const res32 = first ( [ 1 , 2 , 3 ] . map ( x => x + 1 ) )
94
102
95
103
// results are equal!
96
- console . log (
97
- `first([1,2,3]).map( x => x + 1 ) : ` ,
104
+ console . log ( `
105
+ first([1,2,3])
106
+ .map( x => x + 1 ) : ` ,
98
107
res31
99
108
)
100
- console . log (
101
- `first([1,2,3].map( x => x + 1 ))` ,
109
+ console . log ( `
110
+ first([1,2,3]
111
+ .map( x => x + 1 )) :` ,
102
112
res32
103
113
)
104
114
0 commit comments