slightlyoff / Promises

DOM Promises IDL/polyfill
Apache License 2.0
154 stars 28 forks source link

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

Open 0b10011 opened 11 years ago

0b10011 commented 11 years ago

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

slightlyoff commented 11 years ago

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.)?

0b10011 commented 11 years ago

Yeah, that would work for me!