3 ms·
Why not just: require("fs").readdir(".").then(console.log)
by jonny_eh 8y ago
Why 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.