From b3e7d5a476f0c5adb291924654094299b8899d80 Mon Sep 17 00:00:00 2001 From: Eoghan Murray Date: Thu, 15 Oct 2020 06:14:57 +0100 Subject: [PATCH] Prefer a map and a join as feel it's easier to understand, and I found a case in the wild where `Array.prototype.reduce` was overwritten (which admittedly is also a danger with `map`) (#52) --- src/snapshot.ts | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/snapshot.ts b/src/snapshot.ts index 9c9a64c3..0e97033b 100644 --- a/src/snapshot.ts +++ b/src/snapshot.ts @@ -35,10 +35,7 @@ function getCssRulesString(s: CSSStyleSheet): string | null { try { const rules = s.rules || s.cssRules; return rules - ? Array.from(rules).reduce( - (prev, cur) => prev + getCssRuleString(cur), - '', - ) + ? Array.from(rules).map(getCssRuleString).join('') : null; } catch (error) { return null;