I asked this question for PHP a long time ago. The same applies for Node.js the code below seems a little slow when using in a loop - is there a way for writing this in pure Node.js vanilla JavaScript without plugins or React.js etc?
const dirname = 'cdn-assets/'
fs.readdir(dirname, function(err, files) {
if (err) {
// some sort of error
} else {
if (!files.length) {
// directory appears to be empty
}
}
});
Also, can I write a further conditional to check:
if(directory_has_these_files('.js, .css, .jpg, .svg, .mp4'))