Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a note in the README whether it is advised to use fs2 or Node promisified methods #20

Open
madarche opened this issue Oct 15, 2013 · 2 comments
Assignees

Comments

@madarche
Copy link
Contributor

madarche commented Oct 15, 2013

Hello,

Happy and grateful user of deferred I have just discovered https://github.com/medikoo/fs2

Is it recommended to use
a) var readFile = require('fs2').readFile;
or
b) var readFile = promisify(fs.readFile, 1);
?

Thanks!

@ghost ghost assigned medikoo Oct 15, 2013
@medikoo
Copy link
Owner

medikoo commented Oct 15, 2013

Hello @madarche,

I use fs2 in most cases, and would recommend to do that, but it's also important to see that fs2 is not only about returning promises, there are many other things that it offers over native fs.

Also it's important to note one limitation in the way how functions are promisified in fs2. They won't auto-resolve input arguments as function generated bypromisify do, e.g. following works great:

var readFile = promisify(fs.readFile), writeFile = promisify(writeFile);
writeFile(__filename + '.copy', readFile(__filename)).done();

but following won't:

var readFile = fs2.readFile, writeFile = fs2.writeFile
writeFile(__filename + '.copy', readFile(__filename)).done();  // Fail

With fs2 functions, you need to do:

readFile(__filename)(function (content) {
  return writeFile(__filename + '.copy', content);
}).done();

I plan to fix that, and then indeed it'll be good idea to mention it in a doc.

@madarche
Copy link
Contributor Author

Thanks very much @medikoo. I'm now following fs2 closely to know when that happens.

Cheers!

@medikoo medikoo closed this as completed Sep 12, 2016
@medikoo medikoo reopened this Sep 12, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants