-
Notifications
You must be signed in to change notification settings - Fork 28
bluebird-promisell version #29
Conversation
bluebird-promisell.js
Outdated
// readFilesWithDirAndNames :: String -> [String] -> Promise Error [String] | ||
const readFilesWithDirAndNames = R.curryN(2, (dir, fileNames) => { | ||
const readOneFile = readFileWithDirAndName(dir); | ||
return P.traversep(readOneFile)(fileNames); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a pity that with promises we're forced to use specialized functions such as traversep
rather than generalized functions such as traverse
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I agree. I wish I could use R.traverse
, but Promise is not compatible with it. That's why I made the bluebird-promisell
library.
I guess the Task solution can use R.traverse ?
@davidchambers Thanks for your review! I've fixed all your comments. Please take a second look :) |
bluebird-promisell.js
Outdated
const UTF8 = makeEncoding('utf8'); | ||
|
||
// readFileWithDirAndName :: Encoding -> String -> String -> Promise Error String | ||
const readFileWithDirAndName = R.curryN(3, (encoding, dir, name) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason to use R.curryN(3, ...)
rather than R.curry(...)
here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, actually R.curry
is simplier. Updated!
I left two more comments, but otherwise this looks great. Could you squash the commits? |
Thanks @davidchambers ! I fixed those comments. Could you please take another look :) |
bluebird-promisell.js
Outdated
const readFile = R.curry((encoding, filename) => | ||
new Promise((resolve, reject) => { | ||
fs.readFile(filename, {encoding: encoding}, (err, data) => { | ||
if (err) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's use if (err != null)
here to avoid type coercion. I'm sorry that I didn't spot this earlier.
I just noticed one last thing. |
👍 Done :) |
Thanks, @zhangchiqing! I just realized that I no longer have write access to this repository. @amcbride, could you add me as a collaborator? |
🌳 |
The
concatFiles
function is still "big" to me.In this PR,
bluebird-promisell
to break theconcatFiles
function into small ones.