[chore] prettify + config prettier

This commit is contained in:
MathieuG-P
2023-07-01 22:12:47 +02:00
parent 0f85e0dcf9
commit f47a1de05e
330 changed files with 42816 additions and 41968 deletions
+2 -2
View File
@@ -1,7 +1,7 @@
export function splitIntoChunk<T = unknown>(arr: T[], chunkSize: number): T[][] {
const resArr = [];
for(let i = 0; i < arr.length; i += chunkSize){
for (let i = 0; i < arr.length; i += chunkSize) {
resArr.push(arr.slice(i, i + chunkSize));
}
return resArr;
}
}
+8 -6
View File
@@ -1,19 +1,21 @@
export type AllSettledHelperOptions = {
keepStructure?: boolean;
removeFalsy?: boolean;
}
};
export async function allSettled<T>(promises: Promise<T>[], options?: AllSettledHelperOptions): Promise<T[]> {
const settledPromises = await Promise.allSettled(promises);
if(options?.keepStructure){
return settledPromises.map(p => p.status === 'fulfilled' ? p.value : null);
if (options?.keepStructure) {
return settledPromises.map(p => (p.status === "fulfilled" ? p.value : null));
}
return settledPromises.reduce((acc, p) => {
if(p.status === 'fulfilled'){
if(options?.removeFalsy && !p.value){ return acc; }
if (p.status === "fulfilled") {
if (options?.removeFalsy && !p.value) {
return acc;
}
acc.push(p.value);
}
return acc;
}, []);
}
}
+4 -5
View File
@@ -1,9 +1,8 @@
export function isValidUrl(url: string): boolean{
try{
export function isValidUrl(url: string): boolean {
try {
new URL(url);
return true;
}
catch(e){
} catch (e) {
return false;
}
}
}