Chore: more refactor to the bun

This commit is contained in:
SukkaW
2023-11-15 15:20:37 +08:00
parent 37257958c2
commit 071b8120a6
36 changed files with 200 additions and 250 deletions

View File

@@ -0,0 +1,25 @@
import createTrie from './trie';
const domainDeduper = (inputDomains: string[]): string[] => {
const trie = createTrie(inputDomains);
const sets = new Set(inputDomains);
for (let j = 0, len = inputDomains.length; j < len; j++) {
const d = inputDomains[j];
if (d[0] !== '.') {
continue;
}
trie.find(d, false).forEach(f => sets.delete(f));
const a: string = d.slice(1);
if (sets.has(a)) {
sets.delete(a);
}
}
return Array.from(sets);
};
export default domainDeduper;