Add build step to CDN domainset

This commit is contained in:
SukkaW
2023-07-13 22:18:53 +08:00
parent 9fde4a3866
commit b43c1628d6
7 changed files with 128 additions and 48 deletions

View File

@@ -81,6 +81,7 @@ class Trie {
$suffix = suffixStack.pop();
node = nodeStack.pop();
// eslint-disable-next-line guard-for-in -- plain object
for (k in node) {
if (k === SENTINEL) {
if (includeEqualWithSuffix) {
@@ -89,7 +90,6 @@ class Trie {
matches.push($suffix);
}
continue;
}
@@ -161,8 +161,9 @@ class Trie {
node = node[token];
// Prefix does not exist
if (typeof node === 'undefined')
if (typeof node === 'undefined') {
return false;
}
// Keeping track of a potential branch to prune
if (toPrune !== null) {
@@ -170,12 +171,9 @@ class Trie {
toPrune = null;
tokenToPrune = null;
}
}
else {
if (Object.keys(node).length < 2) {
toPrune = parent;
tokenToPrune = token;
}
} else if (Object.keys(node).length < 2) {
toPrune = parent;
tokenToPrune = token;
}
}
@@ -206,8 +204,9 @@ class Trie {
token = suffix[i];
node = node[token];
if (typeof node === 'undefined')
if (typeof node === 'undefined') {
return false;
}
}
return SENTINEL in node;
@@ -217,7 +216,7 @@ class Trie {
* @return {string[]}
*/
dump() {
let node = this.root;
const node = this.root;
const nodeStack = [];
const prefixStack = [];
// Resolving initial prefix
@@ -238,6 +237,7 @@ class Trie {
currentNode = nodeStack.pop();
currentPrefix = prefixStack.pop();
// eslint-disable-next-line guard-for-in -- plain object
for (k in currentNode) {
if (k === SENTINEL) {
hasValue = true;