Chore: introduce eslint to build script

This commit is contained in:
SukkaW
2023-07-12 23:14:20 +08:00
parent aeb90e36ca
commit 09961fad44
20 changed files with 299 additions and 190 deletions

View File

@@ -31,6 +31,24 @@ class Trie {
return this;
}
/**
* @param {string} suffix
*/
contains(suffix) {
let node = this.root;
let token;
for (let i = suffix.length - 1; i >= 0; i--) {
token = suffix[i];
node = node[token];
if (node == null) return false;
}
return true;
}
/**
* Method used to retrieve every item in the trie with the given prefix.
*
@@ -42,8 +60,6 @@ class Trie {
let node = this.root;
const matches = [];
let token;
let i;
let l;
for (let i = suffix.length - 1; i >= 0; i--) {
token = suffix[i];