Promises
Promises copied to clipboard
[polyfill] Add ability to use Promises for core node functions
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
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.)?
Yeah, that would work for me!