From 9312619f2b6839e8cc68abe4d2ef4f0b3a2b1da7 Mon Sep 17 00:00:00 2001 From: Arvin Siva Date: Tue, 30 Jan 2024 15:19:35 -0500 Subject: [PATCH] refactor: simplify boolean check --- src/array.ts | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/src/array.ts b/src/array.ts index 006e40c..3f1ecd2 100644 --- a/src/array.ts +++ b/src/array.ts @@ -228,18 +228,11 @@ Array.prototype.asyncSome = async function ( const asyncResults: Promise[] = []; for (const el of this) { const result = predicate(el); - if (typeof result === "boolean") { - if (result) { - return true; - } - } else { - asyncResults.push(result); - } + if (result === true) return true; + if (result instanceof Promise) asyncResults.push(result); } for (const result of asyncResults) { - if (await result) { - return true; - } + if (await result) return true; } return false; };