4 ms·
Funnily, I was just doing some comparison shopping between different promise libraries as well. Besides avoiding highly nested code, and handling certain types
by iamwil 14y ago
Funnily, I was just doing some comparison shopping between different promise libraries as well.
Besides avoiding highly nested code, and handling certain types of errors better, I've found that they also provide an optional progress callback, in addition to the success and error callbacks in then(). This is highly useful in reporting the progress of a long running process, to help give the user some update or stream the results as it's being completed. That cuts down on both the actual and perceived response time.
In normal callback-style, it's awkward to have two callbacks, one for success/err, and one for progress. In addition, it's not the canonical form for node.js, so we often skip doing it.
As for between the different libs, I've found that Q has one of the better APIs, but it's also the slowest.
https://github.com/kriskowal/q/issues/153 https://github.com/kriskowal/q/issues/153
But that's because it uses Object.freeze(), which the js V8 penalizes with a slowdown, when iterating over it.
http://stackoverflow.com/questions/8435080/any-performance-benefit-to-locking-down-javascript-objects http://stackoverflow.com/questions/8435080/any-performance-b...
- tlrobinson 14y agoThe usage of Object.freeze() was removed recently and is slated for release in v0.9 https://github.com/kriskowal/q/commit/ef6c1b9ce35c7bf3949c7035b877d153af766987 https://github.com/kriskowal/q/commit/ef6c1b9ce35c7bf3949c70...
- iamwil 14y agoAwesome, looking forward to the update, and speedup.