ayojs/ayo

ES6 Promises Instead of Deprecation Warning

ddwwcruz opened this issue · 6 comments

Currently, when using asynchronous functions without callbacks the system gives a deprecation warning. Can it return a promise instead? That way it can be used in an async/await style.

Based on what I know this couldn't be done in Node because of all user's legacy codes.

If all that is blocking is user legacy code, it could potentially be shipped behind a flag (--promises-on-missing-callbacks). That would let us decide on whether to make it default behavior, depending on how many people still use the deprecated versions at some later point in the future.

I am a big fan of the idea, but I don't know how much the deprecated calls are in use, and how many libraries we would potentially break.

Could you please describe in more detail how this would work / what you are looking for?

@Fishrock123 I think this is about making fs.stat(filename) & friends return promises when no callback is passed

@Fishrock123 what @addaleax just described

This sounds like a pretty neat feature. Would be interesting to see how many things it would break but given that the old behavior is already deprecated..?

I definitely wrote multiple promisify in each source file I created today so it sounds like a great quality of life improvement to me. It might be a challenge to do it in a way that doesn't affect performance to badly. Maybe it would actually be easier to have a "promisified" interface of core shipping as separate entry points, either module- or function-wise? That would skip all callback checks immediately.

This is more-or-less requesting a port of nodejs/node#5020, which didn't land in Node at the time.

This sounds like a pretty neat feature. Would be interesting to see how many things it would break but given that the old behavior is already deprecated..?

None. The deprecation is not about the same thing.

@addaleax could you please update the title to reflect the request better?