From dd6bb6a8d3262a729a917ec7b10f5f3e13a79fe7 Mon Sep 17 00:00:00 2001 From: siiky Date: Mon, 23 Oct 2023 10:12:07 +0100 Subject: [PATCH] refactor: map instead of pushing --- lib/plugins.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/plugins.js b/lib/plugins.js index 50442334..60fd51d4 100644 --- a/lib/plugins.js +++ b/lib/plugins.js @@ -250,15 +250,15 @@ function plugins (settings, deviceId) { throw new Error('Denominations and respective counts do not match!') } - const recyclers = [] - _.forEach(it => { - recyclers.push({ + const recyclers = _.map( + it => ({ number: it + 1, name: `recycler${it + 1}`, denomination: parseInt(denominations[it], 10), count: parseInt(counts[it], 10) - }) - }, _.times(_.identity(), numberOfRecyclers)) + }), + _.range(0, numberOfRecyclers) + ) try { return {