Skip to content
This repository was archived by the owner on Feb 18, 2022. It is now read-only.

Commit ce67a24

Browse files
committed
style tweaks
1 parent 7dbbc17 commit ce67a24

File tree

9 files changed

+33
-30
lines changed

9 files changed

+33
-30
lines changed

await.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ require('babel/polyfill');
77
const S = require('sanctuary');
88

99

10-
// readFile :: (Object, String) -> Promise String
10+
// readFile :: (Object, String) -> Promise Error String
1111
const readFile = (options, filename) =>
1212
new Promise((res, rej) => {
1313
fs.readFile(filename, options, (err, data) => {

coroutines-bluebird.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,17 @@ const R = require('ramda');
88
const S = require('sanctuary');
99

1010

11-
// readFile :: String -> String -> Promise String
11+
// readFile :: String -> String -> Promise Error String
1212
const readFile = R.curry((encoding, filename) =>
1313
bluebird.promisify(fs.readFile)(filename, {encoding: encoding})
1414
);
1515

16-
// readFiles :: String -> [String] -> Promise [String]
16+
// readFiles :: String -> [String] -> Promise Error [String]
1717
const readFiles = R.curry((encoding, filenames) =>
1818
bluebird.all(R.map(readFile(encoding), filenames))
1919
);
2020

21-
// walk :: String -> Promise String
21+
// walk :: String -> Promise Error String
2222
const walk = bluebird.coroutine(function*(dir) {
2323
const pathTo = (filename) => path.join(dir, filename);
2424
const index = yield readFile('utf8', pathTo('index.txt'));

coroutines-co.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const R = require('ramda');
88
const S = require('sanctuary');
99

1010

11-
// readFile :: String -> String -> Promise String
11+
// readFile :: String -> String -> Promise Error String
1212
const readFile = R.curry((encoding, filename) =>
1313
new Promise((res, rej) => {
1414
fs.readFile(filename, {encoding: encoding}, (err, data) => {
@@ -21,7 +21,7 @@ const readFile = R.curry((encoding, filename) =>
2121
})
2222
);
2323

24-
// readFiles :: String -> [String] -> Promise [String]
24+
// readFiles :: String -> [String] -> Promise Error [String]
2525
const readFiles = R.curry((encoding, filenames) =>
2626
Promise.all(R.map(readFile(encoding), filenames))
2727
);

kgo.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,12 @@ const R = require('ramda');
99
const S = require('sanctuary');
1010

1111

12-
// join :: String -> String -> String
12+
// join :: String -> String -> String
1313
const join = R.curryN(2, path.join);
1414

15-
// data Text = Buffer | String
16-
// readFile :: String -> String -> ((Error?, Text?) -> Unit) -> Unit
15+
// data Text = Buffer | String
16+
// readFile ::
17+
// String -> String -> ((Error?, Text?) -> Undefined) -> Undefined
1718
const readFile = R.curry((encoding, filename, callback) => {
1819
fs.readFile(filename, {encoding: encoding}, callback);
1920
});

lazy-either.js

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,35 +7,36 @@ const LazyEither = require('lazy-either');
77
const R = require('ramda');
88
const S = require('sanctuary');
99

10-
// join :: String -> String -> String
10+
11+
// join :: String -> String -> String
1112
const join = R.curryN(2, path.join);
1213

13-
// readFile :: String -> String -> LazyEither Error String
14+
// readFile :: String -> String -> LazyEither Error String
1415
const readFile = R.curry((encoding, filename) =>
1516
new LazyEither(resolve => {
16-
fs.readFile(filename, {encoding: encoding}, (err, data) =>
17-
resolve(err !== null ? S.Left(err) : S.Right(data)));
17+
fs.readFile(
18+
filename,
19+
{encoding: encoding},
20+
(err, data) => resolve(err != null ? S.Left(err) : S.Right(data))
21+
);
1822
}));
1923

20-
// readFiles :: [String] -> LazyEither Error String
21-
const readFiles = R.traverse(LazyEither.of, readFile('utf8'));
22-
23-
// concatFiles :: String -> LazyEither Error String
24+
// concatFiles :: String -> LazyEither Error String
2425
const concatFiles = dir =>
2526
S.pipe([readFile('utf8'),
2627
R.map(S.lines),
2728
R.map(R.map(join(dir))),
28-
R.chain(readFiles),
29+
R.chain(R.traverse(LazyEither.of, readFile('utf8'))),
2930
R.map(R.join(''))],
3031
join(dir, 'index.txt'))
3132

33+
3234
const main = () => {
3335
concatFiles(process.argv[2]).value(either => {
3436
if (either.isRight) {
3537
process.stdout.write(either.value);
3638
process.exit(0);
37-
}
38-
else {
39+
} else {
3940
process.stderr.write(String(either.value) + '\n');
4041
process.exit(1);
4142
}

promises-ramda.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,16 @@ const R = require('ramda');
99
const S = require('sanctuary');
1010

1111

12-
// join :: String -> String -> String
12+
// join :: String -> String -> String
1313
const join = R.curryN(2, path.join);
1414

15-
// readFile :: Object -> String -> Promise String
15+
// readFile :: Object -> String -> Promise Error String
1616
const readFile = S.flip(Promise.promisify(fs.readFile));
1717

18-
// then :: (a -> b) -> Promise a -> Promise b
18+
// then :: (a -> b) -> Promise e a -> Promise e b
1919
const then = R.invoker(1, 'then');
2020

21-
// concatFiles :: String -> Promise String
21+
// concatFiles :: String -> Promise Error String
2222
const concatFiles = dir =>
2323
S.pipe([join(R.__, 'index.txt'),
2424
readFile({encoding: 'utf8'}),

promises.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const path = require('path');
66
const S = require('sanctuary');
77

88

9-
// readFile :: (Object, String) -> Promise String
9+
// readFile :: (Object, String) -> Promise Error String
1010
const readFile = (options, filename) =>
1111
new Promise((res, rej) => {
1212
fs.readFile(filename, options, (err, data) => {

righto.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@ const path = require('path');
66
const righto = require('righto');
77

88

9-
// readFile :: String -> String -> Righto String
9+
// readFile :: String -> String -> Righto String
1010
const readFile = dir => file =>
1111
righto(fs.readFile, path.join(dir, file), {encoding: 'utf8'});
1212

13+
1314
const main = () => {
1415
const dir = process.argv[2];
1516

tasks.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ const R = require('ramda');
88
const S = require('sanctuary');
99

1010

11-
// join :: String -> String -> String
11+
// join :: String -> String -> String
1212
const join = R.curryN(2, path.join);
1313

14-
// data Text = Buffer | String
15-
// readFile :: String -> String -> Task Error Text
14+
// data Text = Buffer | String
15+
// readFile :: String -> String -> Task Error Text
1616
const readFile = R.curry((encoding, filename) =>
1717
new Task((rej, res) => {
1818
fs.readFile(filename, {encoding: encoding}, (err, data) => {
@@ -25,7 +25,7 @@ const readFile = R.curry((encoding, filename) =>
2525
})
2626
);
2727

28-
// concatFiles :: String -> Task Error String
28+
// concatFiles :: String -> Task Error String
2929
const concatFiles = dir =>
3030
S.pipe([readFile('utf8'), // :: Task Error String
3131
R.map(S.lines), // :: Task Error [String]

0 commit comments

Comments
 (0)