refactor: avoid using unnecessary variables

This commit is contained in:
siiky 2023-10-23 10:23:36 +01:00
parent bec0ec4ee6
commit 0085c22003

View file

@ -161,9 +161,11 @@ function plugins (settings, deviceId) {
return _.map(([acc, bill]) => acc + bill.provisioned, _.zip(sum, bills))
}
const provisioned = _.reduce(sumTxs, _.map(_.constant(0), recyclers), redeemableTxs)
const zipped = _.zip(_.map('count', recyclers), provisioned)
const counts = _.map(r => r[0] - r[1], zipped)
const counts = _.flow(
_.reduce(sumTxs, _.map(_.constant(0), recyclers)),
_.zip(_.map('count', recyclers)),
_.map(([count, provisioned]) => count - provisioned),
)(redeemableTxs)
if (_.some(_.lt(_, 0), counts)) {
throw new Error('Negative note count: %j', counts)