A ponyfill for
fs.readdir(path, { withFileTypes: true })
npm install --save readdir-withfiletypes
Before: No support for Node <10
import fs from "fs"
fs.readdir("./dir", { withFileTypes: true }, (err, dirents) => {
// ...
})
let dirents = readdirSync("./dir", { withFileTypes: true })
After: Support for Node <10
import { readdir, readdirSync } from "readdir-withFileTypes"
readdir("./dir", { withFileTypes: true }, (err, dirents) => {
// ...
})
let dirents = readdirSync("./dir", { withFileTypes: true })