Comparison to js-csp
Closed this issue · 2 comments
Very interesting library. Thank you for sharing. I’d be interested to know wether you have some perspective on how this implementation compares to the more popular generator based js-csp library.
They have an issue about using async instead of generators but it doesn’t contain much information on the trade offs.
js-csp/js-csp#73
I would agree with their sentiment -- adding promises to the interface does add overhead, and it's probably not inconsequential. There are potentially a lot of unresolved promises floating around at any given time when using async-csp
, and the concern about performing within try/catch
blocks for the promises is also valid. I can't say for sure exactly how much overhead the promises add, because I haven't profiled them in similar scenarios, but I can't imagine async-csp
would be the faster of the two.
However, personally, it's overhead that I find quite useful. Most of the javascript / typescript / etc code I write today makes heavy use of async / await
(or at least chained promises), so I find myself wanting to continue interfacing with promises anyways.
Thanks for the response. I totally agree with you that Promises make for a much more concise API that allows easy interoparability with other parts of the code. I'll have an eye on performance though.