@@ -11,35 +11,35 @@ const { runNode, Promise: CreedPromise } = require('creed')
1111
1212// readFilePromise :: String -> String -> Promise Error Buffer
1313const readFilePromise = ( fileName , encoding = 'utf-8' ) =>
14- runNode ( fs . readFile , fileName , { encoding} )
14+ runNode ( fs . readFile , fileName , { encoding} )
1515
1616// wrap into List that provides 'traverse'
1717const files = List ( [ 'file1.txt' , 'file2.txt' ] )
1818
1919console . log (
2020 `Running...
2121 List(['file1.txt', 'file2.txt'])
22- .traverse( CreedPromise.of, readFilePromise )
23- .then( console.log, console.error ) :
22+ .traverse( CreedPromise.of, readFilePromise )
23+ .then( console.log, console.error ) :
2424 `
2525)
2626
2727/*
28- 'files' is List of files 'List(a)'
29- 'map' preserves the List wrapper, so we can get 'List(Promise(a))'
30- 'traverse' applies the function (a -> f b) to each List entry,
31- then lifts the List to Promise of Lists via CreedPromise's 'ap' operator
32- running Promises in parallel!
28+ 'files' is List of files 'List(a)'
29+ 'map' preserves the List wrapper, so we can get 'List(Promise(a))'
30+ 'traverse' applies the function (a -> f b) to each List entry,
31+ then lifts the List to Promise of Lists via CreedPromise's 'ap' operator
32+ running Promises in parallel!
3333*/
3434
3535files
3636 . traverse (
3737
38- // type hint, applicative functor
39- // needed in case of failure or never running the function
40- CreedPromise . of ,
38+ // type hint, applicative functor
39+ // needed in case of failure or never running the function
40+ CreedPromise . of ,
4141
42- // traversing function a -> f b
43- file => readFilePromise ( file )
42+ // traversing function a -> f b
43+ file => readFilePromise ( file )
4444 )
4545 . then ( console . log , console . error )
0 commit comments