]> git.lizzy.rs Git - local-nhentai.git/blobdiff - stats-doujins.js
Generic stats and select
[local-nhentai.git] / stats-doujins.js
index 6d7b0e5f6495af939d91a392ef764411053e2698..47a25a189761572d3979e231c1584b69b07fe8c7 100644 (file)
@@ -1,14 +1,12 @@
 const info = require("./info")
 const du = require("./du")
 
-const fmt = (num, size) => 
+const fmt = (num, size) =>
 `Number of doujins:       ${num}
 Total size:              ${(size       / 1e9).toFixed(2)}GB
 Average size per doujin: ${(size / num / 1e6).toFixed(2)}MB`
 
 info.doujins()
        .then(doujins => Object.keys(doujins))
-       .then(doujins => Promise.all(doujins.map(du))
-               .then(sizes => sizes.reduce((a, b) => a + b, 0))
-               .then(total => console.log(fmt(doujins.length, total)))
-       )
+       .then(doujins => du(doujins)
+               .then(total => console.log(fmt(doujins.length, total))))