From 038353b89cdeb2998876dbc3642abe235706c6c2 Mon Sep 17 00:00:00 2001 From: Rick Hanlon Date: Thu, 31 Oct 2019 21:08:41 -0700 Subject: [PATCH] LogBox - switch to array filter Summary: Fixes a bug for old versions of JSC that do not support `for of` syntax Changelog: [Internal] Reviewed By: fkgozali Differential Revision: D18265611 fbshipit-source-id: 4643b6e2571c57ddd982661d188c3449f17a151e --- Libraries/LogBox/Data/LogBoxData.js | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/Libraries/LogBox/Data/LogBoxData.js b/Libraries/LogBox/Data/LogBoxData.js index eff51a67bb2..c914775a1e3 100644 --- a/Libraries/LogBox/Data/LogBoxData.js +++ b/Libraries/LogBox/Data/LogBoxData.js @@ -56,9 +56,7 @@ function handleUpdate(): void { updateTimeout = setImmediate(() => { updateTimeout = null; const logsSet = _isDisabled ? new Set() : logs; - for (const {observer} of observers) { - observer(logsSet); - } + observers.forEach(({observer}) => observer(logsSet)); }); } } @@ -200,11 +198,9 @@ export function addIgnorePatterns( // This allows adding an ignore pattern anywhere in the codebase. // Without this, if you ignore a pattern after the a log is created, // then we would keep showing the log. - for (let log of logs) { - if (isMessageIgnored(log.message.content)) { - logs.delete(log); - } - } + logs = new Set( + Array.from(logs).filter(log => !isMessageIgnored(log.message.content)), + ); } handleUpdate(); }