Skip to content

Commit

Permalink
refactor: simplify boolean check
Browse files Browse the repository at this point in the history
  • Loading branch information
arvinsiva committed Jan 30, 2024
1 parent 07f1f3f commit 9312619
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions src/array.ts
Original file line number Diff line number Diff line change
Expand Up @@ -228,18 +228,11 @@ Array.prototype.asyncSome = async function <T>(
const asyncResults: Promise<boolean>[] = [];
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;
};
Expand Down

0 comments on commit 9312619

Please sign in to comment.