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

Function pEveryFunction

source/helpers/p-utils.ts:54–81  ·  view source on GitHub ↗
(
	iterable: List,
	predicate: (value: Element) => Promisable<boolean>,
)

Source from the content-addressed store, hash-verified

52}
53
54export function pEveryFunction<
55 List extends Iterable<unknown>,
56 Element extends IterableElement<List>,
57>(
58 iterable: List,
59 predicate: (value: Element) => Promisable<boolean>,
60): Promisable<boolean> {
61 const promises: Array<PromiseLike<boolean>> = [];
62 // Prioritize sync functions and early returns
63 for (const item of iterable) {
64 const result = predicate(item as Element);
65 if (typeof result === 'boolean') {
66 if (!result) {
67 // Early sync return on the first falsy value
68 return false;
69 }
70 } else {
71 promises.push(result);
72 }
73 }
74
75 if (promises.length === 0) {
76 // Matches `[].every(Boolean)`
77 return true;
78 }
79
80 return pEvery(promises);
81}

Callers 1

shouldFeatureRunFunction · 0.85

Calls 1

pEveryFunction · 0.85

Tested by

no test coverage detected