mirror of
https://github.com/Zagrios/bs-manager.git
synced 2026-07-03 14:08:25 +02:00
[chore] prettify + config prettier
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}, []);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user