3 ms·
I find it really bizarre that Node still doesn't have full promisified built-in libraries. It's not like it'd break existing APIs.
by jonny_eh 8y ago
I find it really bizarre that Node still doesn't have full promisified built-in libraries. It's not like it'd break existing APIs.
- dvlsg 8y agoI think they're testing natively provided promise APIs with the fs module. https://github.com/nodejs/node/pull/18297 https://github.com/nodejs/node/pull/18297 It's of course not a full promisification of every built in, but it looks like theyre at least trying it out.
- tlrobinson 8y agoNode 10 has fs, at least: require("fs").promises.readdir(".").then(console.log)
- jonny_eh 8y agoWhy not just: require("fs").readdir(".").then(console.log)
- tlrobinson 8y agoThat's the legacy callback version. In practice you'd probably do: const fs = require("fs").promises; // ... fs.readdir(".").then(console.log);
- kjeetgill 8y agoAh, thats pretty nice. The previous example was pretty janky but I didn't foresee it being used like this. Eyes opened.
- salehenrahman 8y agoIt can potentially break things. There are legacy code that assume that calling `readdir` will yield undefined, and will have just passed that result to a function, that alters its behaviour based on whether a parameter is undefined.
- jonny_eh 8y agoInteresting. Seems like a great opportunity for a major version bump.