From c954b8f66e41785375570f0879f2afa17cbd496e Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Sat, 14 Jun 2025 09:26:26 -0300 Subject: sugar: make accumulateSum set-aware --- src/common-util/sugar.js | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src') diff --git a/src/common-util/sugar.js b/src/common-util/sugar.js index 48442b13..9116698f 100644 --- a/src/common-util/sugar.js +++ b/src/common-util/sugar.js @@ -116,6 +116,10 @@ export function findIndexOrEnd(array, fn) { // returns null (or values in the array are nullish), they'll just be skipped in // the sum. export function accumulateSum(array, fn = x => x) { + if (!Array.isArray(array)) { + return accumulateSum(Array.from(array, fn)); + } + return array.reduce( (accumulator, value, index, array) => accumulator + -- cgit 1.3.0-6-gf8a5