V1 with working cmdline interface for easy of using GIT

This commit is contained in:
s41r4j
2025-08-08 16:27:43 +05:30
commit 71a398820a
2845 changed files with 396687 additions and 0 deletions
+23
View File
@@ -0,0 +1,23 @@
/**
* Like `Promise.allSettled()` but throws an error if any promises are rejected.
*/
export const allSettledWithThrow = async <R>(promises: Promise<R>[]): Promise<R[]> => {
const results = await Promise.allSettled(promises);
const rejected = results.filter((result): result is PromiseRejectedResult => result.status === 'rejected');
if (rejected.length) {
for (const result of rejected) {
console.error(result.reason);
}
throw new Error(`${rejected.length} promise(s) failed - see the above errors`);
}
// Note: TS was complaining about using `.filter().map()` here for some reason
const values: R[] = [];
for (const result of results) {
if (result.status === 'fulfilled') {
values.push(result.value);
}
}
return values;
};