Chore: housekeeping

This commit is contained in:
SukkaW
2023-12-07 21:06:34 +08:00
parent 0a45537fdc
commit e16c318f4c
5 changed files with 14 additions and 11 deletions

View File

@@ -30,7 +30,8 @@ export const buildAntiBogusDomain = task(import.meta.path, async () => {
const result = [];
for await (const line of readFileByLine(path.resolve(import.meta.dir, '../Source/ip/reject.conf'))) {
if (line === '# --- [Anti Bogus Domain Replace Me] ---') {
(await bogusIpPromise).forEach(rule => result.push(rule));
// bogus ip is less than 200, no need to worry about "Maximum call stack size exceeded"
result.push(...(await bogusIpPromise));
continue;
} else {
const l = processLine(line);

View File

@@ -1,6 +1,8 @@
import { createTrie } from './trie';
export const domainDeduper = (inputDomains: string[]): string[] => {
export function domainDeduper(inputDomains: string[], toArray?: true): string[];
export function domainDeduper(inputDomains: string[], toArray: false): Set<string>;
export function domainDeduper(inputDomains: string[], toArray = true): string[] | Set<string> {
const trie = createTrie(inputDomains);
const sets = new Set(inputDomains);
@@ -19,7 +21,11 @@ export const domainDeduper = (inputDomains: string[]): string[] => {
}
}
return Array.from(sets);
};
if (toArray) {
return Array.from(sets);
}
return sets;
}
export default domainDeduper;