Chore: minor changes

This commit is contained in:
SukkaW
2023-11-17 21:36:09 +08:00
parent f88c3648a2
commit a5e36a1cd8
10 changed files with 51 additions and 50 deletions

View File

@@ -56,7 +56,6 @@ export async function* createReadlineInterfaceFromResponse(resp: Response): Asyn
}
}
export async function fetchRemoteTextAndCreateReadlineInterface(url: string | URL, opt?: RequestInit): Promise<AsyncGenerator<string>> {
const resp = await fetchWithRetry(url, opt);
return createReadlineInterfaceFromResponse(resp);
export function fetchRemoteTextAndCreateReadlineInterface(url: string | URL, opt?: RequestInit): Promise<AsyncGenerator<string>> {
return fetchWithRetry(url, opt).then(res => createReadlineInterfaceFromResponse(res));
}

View File

@@ -68,7 +68,7 @@ export async function processDomainLists(domainListsUrl: string | URL) {
}
export async function processHosts(hostsUrl: string | URL, includeAllSubDomain = false) {
console.time(` - processHosts: ${hostsUrl}`);
console.time(`- processHosts: ${hostsUrl}`);
if (typeof hostsUrl === 'string') {
hostsUrl = new URL(hostsUrl);

View File

@@ -18,6 +18,12 @@ const traceAsync = async <T>(prefix: string, fn: () => Promise<T>): Promise<T> =
};
export { traceAsync };
export interface TaskResult {
readonly start: number;
readonly end: number;
readonly taskName: string;
}
const task = <T>(__filename: string, fn: () => Promise<T>, customname: string | null = null) => {
const taskName = customname ?? path.basename(__filename, path.extname(__filename));
return async () => {
@@ -27,7 +33,7 @@ const task = <T>(__filename: string, fn: () => Promise<T>, customname: string |
const end = performance.now();
console.log(`✅ [${taskName}] Executed successfully: ${(end - start).toFixed(3)}ms`);
return { start, end, taskName } as const;
return { start, end, taskName } as TaskResult;
};
};
export { task };