From 7179d3cc89dcd7a4bd296998ec19eea457b1f012 Mon Sep 17 00:00:00 2001 From: eclipse Date: Sat, 7 Oct 2023 10:33:34 +0200 Subject: [PATCH] streamlined code for getFilesAndSizes() --- updown.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/updown.js b/updown.js index a7f2ea5..5f73523 100644 --- a/updown.js +++ b/updown.js @@ -7,9 +7,8 @@ const staticPath = "public/"; app.set("view engine", "pug"); function getFilesAndSizes(path) { - var filenames = fs.readdirSync(path); - var files = []; - filenames.forEach(filename => { + let files = []; + fs.readdirSync(path).forEach(filename => { files.push({ name: filename, size: fs.statSync(path + filename, (e, s) => s).size }); }) console.log(files);