Skip to content

Commit 194f950

Browse files
committed
improve readability
1 parent e437ada commit 194f950

File tree

2 files changed

+32
-19
lines changed

2 files changed

+32
-19
lines changed

examples/23-structure-asyncing.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,10 @@ const routes = Map({
2020
blog: '/blog'
2121
})
2222

23-
console.log(
24-
`Map({home: '/', about: '/about-us', blog: '/blog'}).traverse(Task.of, route => httpGet(route, {})).fork(..., ...) : `
23+
console.log(`
24+
Map({home: '/', about: '/about-us', blog: '/blog'})
25+
.traverse(Task.of, route => httpGet(route, {}))
26+
.fork(..., ...) : `
2527
)
2628

2729
// apply the 2nd argument function to each route
@@ -52,7 +54,8 @@ Map({
5254

5355
// need to wrap into 'List' providing 'traverse'
5456
List(routes).traverse(
55-
Task.of, route => httpGet(route, {})
57+
Task.of,
58+
route => httpGet(route, {})
5659
)
5760
)
5861
.fork( console.error, console.log )

examples/24-natural-transformations.js

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,19 @@ const eitherToTask = e =>
88
e.fold(Task.rejected, Task.of)
99

1010

11-
console.log(
12-
`eitherToTask(Right('nightingale')).fork(..., ...) : `
11+
console.log(`
12+
eitherToTask(Right('nightingale'))
13+
.fork(..., ...) : `
1314
)
1415
eitherToTask(Right('nightingale'))
1516
.fork(
1617
e => console.error('Error: ', e),
1718
res => console.log('Result: ', res)
1819
)
1920

20-
console.log(
21-
`eitherToTask(Left('errrr')).fork(..., ...) : `
21+
console.log(`
22+
eitherToTask(Left('errrr'))
23+
.fork(..., ...) : `
2224
)
2325
eitherToTask(Left('errrr'))
2426
.fork(
@@ -44,12 +46,16 @@ const res2 = boxToEither(
4446
)
4547

4648
// 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+
`,
4953
res1
5054
)
51-
console.log(
52-
`boxToEither(Box(100).map( x => x * 2 )) : `,
55+
console.log(`
56+
boxToEither(Box(100)
57+
.map( x => x * 2 )) :
58+
`,
5359
res2
5460
)
5561

@@ -72,12 +78,14 @@ const res22 = boxToEitherBad(
7278
)
7379

7480
// 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 ) : `,
7784
res21
7885
)
79-
console.log(
80-
`boxToEitherBad(Box(100).map( x => x * 2 )) : `,
86+
console.log(`
87+
boxToEitherBad(Box(100)
88+
.map( x => x * 2 )) : `,
8189
res22
8290
)
8391

@@ -93,12 +101,14 @@ const res31 = first([1,2,3]).map( x => x + 1 )
93101
const res32 = first( [1,2,3].map( x => x + 1 ) )
94102

95103
// 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 ) : `,
98107
res31
99108
)
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 )) :`,
102112
res32
103113
)
104114

0 commit comments

Comments
 (0)