From 393e149b91c1f459a30e9f62990f2e8342ef6f0e Mon Sep 17 00:00:00 2001 From: siiky Date: Wed, 3 Jul 2024 13:05:12 +0100 Subject: [PATCH] refactor: extract `stat()` out of `cleanOldFailedPDF417Scans()` --- lib/poller.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/poller.js b/lib/poller.js index 02834902..b3bba26b 100644 --- a/lib/poller.js +++ b/lib/poller.js @@ -143,6 +143,8 @@ const readdirRec = rootPath => )) .then(_.flatten) +const stat = path => fs.stat(path).then(_.set('path', path)) + // @see lib/customers.js:updateIdCardData() const cleanOldFailedPDF417Scans = () => { let old = new Date() @@ -156,7 +158,7 @@ const cleanOldFailedPDF417Scans = () => { .then(entries => Promise.all( entries .filter(entry => entry.isFile()) - .map(entry => fs.stat(entry.path).then(_.set('path', entry.path))) + .map(entry => stat(entry.path)) )) .then(filestats => Promise.all( filestats