Closed iliocatallo closed 8 years ago
Task#taskify
is already provided by @stoeffel's Futurize library (https://github.com/stoeffel/futurize) :3
I'm particularly against the concept of Task#taskifyAll
(and Promise#promisifyAll
, for that matter), since it creates APIs that are not supposed to exist, e.g.:
var events = new EventEmitter();
Task.taskifyAll(events);
events.onAsync(function(){ ... }); // what does this even mean?
If you still want to write it, you can implement it as:
var futurize = require('futurize')(require('data.task'));
function taskifyAll(o) {
Object.keys(o).forEach(function(key) {
o[key + 'Async'] = futurize(o[key])
});
return o;
}
Hi,
thank you for your prompt answer. I understand your concern about the possibility of creating non-sensical APIs. On the other hand, one could argue that programming is inherently an unsafe activity, and that - in this specific case - the price to pay for defending the developer from herself is way too high to be acceptable.
Thank you again for your great library.
Hi,
It would be really convenient to augment
Task
so as to include two additional helper methods:Task#taskify
andTask#taskifyAll
(similarly to what provided by Bluebird for promises). This would allow avoiding manual wrapping such as:for each single async. function in the codebase.
Thank you!