MCPcopy Index your code
hub / github.com/refined-github/refined-github / pSome

Function pSome

source/helpers/p-utils.ts:3–18  ·  view source on GitHub ↗
(iterable: Iterable<PromiseLike<unknown>>)

Source from the content-addressed store, hash-verified

1import type {IterableElement, Promisable} from 'type-fest';
2
3async function pSome(iterable: Iterable<PromiseLike<unknown>>): Promise<boolean> {
4 // eslint-disable-next-line no-async-promise-executor -- It's fine, resolve is at the end
5 return new Promise(async resolve => {
6 for (const promise of iterable) {
7 (async () => {
8 if (await promise) {
9 resolve(true);
10 }
11 })();
12 }
13
14 await Promise.allSettled(iterable);
15
16 resolve(false);
17 });
18}
19
20async function pEvery(iterable: Iterable<PromiseLike<unknown>>): Promise<boolean> {
21 const results = await Promise.all(iterable);

Callers 1

pSomeFunctionFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected