3 ms·
util.promisify() seems to work for many of the node stuff I use a lot, like pipeline(), readFile(), etc. Perhaps require('xyz/promises') is a newer development.
by prussian 6y ago
util.promisify() seems to work for many of the node stuff I use a lot, like pipeline(), readFile(), etc. Perhaps require('xyz/promises') is a newer development.
- spion 6y agodo you really want to keep util.promisifying everything? I know I don't. Streams (and event emitters, and the ecosystem bits that rely on them) still haven't fully caught up with promises either, e.g. async iterators and generators are still quite awkward
- prussian 6y agolate reply. I've sort of experimented with async iterators and using pipeline() to pipe them together and it seems to work out for the most part; not sure what is awkward about them, I mean consume with an async iter on the source passed as an arg and you can throw at any time to kill it with an error. In fact I find the new async generator transforms easier and more ergonomic. in terms of event emitters. I can just use `await once(emiter, 'event');` now. Not sure how .on would be expected to work outside of it being some kind of async iterator. I mean, I don't mind using util.promisify or just importing the "to be" xyz/promises paths. The code exists clearly, either behind a symbol or otherwise.
- spion 6y agoCompare with the Dart stream API: https://api.dart.dev/stable/2.12.2/dart-async/Stream-class.html https://api.dart.dev/stable/2.12.2/dart-async/Stream-class.h...
- ianwalter 6y agoWhy util.promisify `readFile` when `fs` exports promises?
- tdy_err 6y agoOf course. It’s just new to users, relatively; only since 2019. To boot, one of the current LTS versions -the oldest- does not include it