Promises icon indicating copy to clipboard operation
Promises copied to clipboard

[polyfill] Add ability to use Promises for core node functions

Open 0b10011 opened this issue 11 years ago • 2 comments

Something like:

var readFile = Promise.nodeConvert(fs.readFile);
return readFile("foo.txt", "utf-8");

Q Docs: https://github.com/kriskowal/q#adapting-node

Q Code: https://github.com/kriskowal/q/blob/master/q.js#L1655-L1693

0b10011 avatar Jul 03 '13 19:07 0b10011

Hrm, I like this...and having it on the static seems best. It'd be great if it were more generic, though, and didn't include "node" in the name.

WDYT about Promise.bind(func, scope?, style?) where scope is an optional scope to bind the function to (Q's nbind) and style is some arity or string that tells you about the conventions the function otherwise uses (one callback, two, etc.)?

slightlyoff avatar Jul 11 '13 15:07 slightlyoff

Yeah, that would work for me!

0b10011 avatar Jul 11 '13 16:07 0b10011