From 5c8636d7b3e6bb74ea174eb2f70082a536eca96b Mon Sep 17 00:00:00 2001 From: SukkaW Date: Fri, 20 Sep 2024 16:10:19 +0800 Subject: [PATCH] Minor changes here and there --- Build/lib/stable-sort-domain.ts | 4 ++-- Build/lib/trie.ts | 12 ++++++++---- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/Build/lib/stable-sort-domain.ts b/Build/lib/stable-sort-domain.ts index 0d19eb1f..ac346c98 100644 --- a/Build/lib/stable-sort-domain.ts +++ b/Build/lib/stable-sort-domain.ts @@ -28,8 +28,8 @@ export const buildParseDomainMap = (inputs: string[]) => { export const sortDomains = ( inputs: string[], - domainMap?: Map, - subdomainMap?: Map + domainMap?: Map | null, + subdomainMap?: Map | null ) => { if (!domainMap || !subdomainMap) { const { domainMap: dm, subdomainMap: sm } = buildParseDomainMap(inputs); diff --git a/Build/lib/trie.ts b/Build/lib/trie.ts index fbff4f10..0a0db1d8 100644 --- a/Build/lib/trie.ts +++ b/Build/lib/trie.ts @@ -369,12 +369,16 @@ export const createTrie = (from?: string[] | Set | null, smo : false; }; - const dump = () => { + function dump(onSuffix: (suffix: string) => void): void; + function dump(): string[]; + function dump(onSuffix?: (suffix: string) => void): string[] | void { const results: string[] = []; - walk(suffix => { - results.push(fastStringArrayJoin(suffix, '')); - }); + const handleSuffix = onSuffix + ? (suffix: string[]) => onSuffix(fastStringArrayJoin(suffix, '')) + : (suffix: string[]) => results.push(fastStringArrayJoin(suffix, '')); + + walk(handleSuffix); return results; };