Skip to content

Commit 12aa7c7

Browse files
committed
add creed lib
1 parent b8dbb68 commit 12aa7c7

File tree

14 files changed

+99
-419
lines changed

14 files changed

+99
-419
lines changed

examples/02-identity-double-wrap.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ const applyDiscount = (price, discount) =>
6363
// without fold, result is wrapped into Box twice
6464
const applyDiscountInBox = (price, discount) =>
6565
moneyToFloat(price).map(cost =>
66+
67+
// nesting so cost remains in scope
6668
percentToFloat(discount).map(savings =>
6769
cost - cost * savings
6870
)
@@ -76,5 +78,8 @@ const result = applyDiscount('$55', '20%')
7678

7779
console.log(`applyDiscount('$55', '20%') : `, result) //=> 44
7880

79-
console.log(`applyDiscountInBox('$55', '20%') : `, applyDiscountInBox('$55', '20%')) //=> Box(Box(44))
81+
console.log(
82+
`applyDiscountInBox('$55', '20%') : `,
83+
applyDiscountInBox('$55', '20%')
84+
) //=> Box(Box(44))
8085

examples/03-right-left.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,5 +123,8 @@ const badColorNew = findColorFromNullable('gray')
123123
c => c.toUpperCase()
124124
)
125125

126-
console.log(`findColorFromNullable('gray') transformed and fold with (e => 'no color', c => c.toUpperCase()) is: `, badColorNew) //=> no color
126+
console.log(
127+
`findColorFromNullable('gray') transformed and fold with (e => 'no color', c => c.toUpperCase()) is: `,
128+
badColorNew
129+
) //=> no color
127130

examples/04-fs-error-handling.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ const getPort = fileName =>
5151

5252
// this will not "explode" if fileName is not found!
5353
tryCatch( () => fs.readFileSync(fileName) )
54-
.map(c => JSON.parse(c))
54+
.map( c => JSON.parse(c) )
5555

5656
// .map(c => tryCatch(() => JSON.parse(c)))
5757
.fold(
@@ -74,8 +74,8 @@ console.log(`getPort('config.json') : `, getPort('config.json')) //=> 8080
7474

7575
// protecting against further errors by wrapping into tryCatch
7676
const getPortSafe = fileName =>
77-
tryCatch(() => fs.readFileSync(fileName))
78-
.chain(c => tryCatch(() => JSON.parse(c)))
77+
tryCatch( () => fs.readFileSync(fileName) )
78+
.chain( c => tryCatch(() => JSON.parse(c)) )
7979
.fold(
8080
e => 3000,
8181
c => c.port

examples/12-task.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ const showErr = e => console.log('err :', e)
44
const showSuc = x => console.log('success: ', x)
55

66
const formTask = val =>
7-
Task.of(val)
8-
.fork( showErr, showSuc )
7+
Task.of( val )
8+
.fork( showErr, showSuc )
99

1010
console.log(`formTask(44) : `)
1111
formTask(44)

examples/yarn.lock

Lines changed: 0 additions & 11 deletions
This file was deleted.

includes/config.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"a": "b",
3+
"port": 8080
4+
}

includes/config1-fl.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"a": "b",
3+
"port": 7070
4+
}

includes/config1.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"a": "b",
3+
"port": 6060
4+
}

includes/config2.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"a": "b",
3+
"port": 6060
4+
}

includes/configBad.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"a": "b",
3+
}

0 commit comments

Comments
 (0)