Browse Source

Minor changes here and there

SukkaW 1 year ago
parent
commit
5c8636d7b3
2 changed files with 10 additions and 6 deletions
  1. 2 2
      Build/lib/stable-sort-domain.ts
  2. 8 4
      Build/lib/trie.ts

+ 2 - 2
Build/lib/stable-sort-domain.ts

@@ -28,8 +28,8 @@ export const buildParseDomainMap = (inputs: string[]) => {
 
 export const sortDomains = (
   inputs: string[],
-  domainMap?: Map<string, string>,
-  subdomainMap?: Map<string, string>
+  domainMap?: Map<string, string> | null,
+  subdomainMap?: Map<string, string> | null
 ) => {
   if (!domainMap || !subdomainMap) {
     const { domainMap: dm, subdomainMap: sm } = buildParseDomainMap(inputs);

+ 8 - 4
Build/lib/trie.ts

@@ -369,12 +369,16 @@ export const createTrie = <Meta = any>(from?: string[] | Set<string> | 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;
   };