mirror of
https://codeberg.org/yeentown/barkey
synced 2024-11-25 08:15:12 +00:00
add comments for mute logic
This commit is contained in:
parent
72d59b459a
commit
7ad36d33e9
1 changed files with 4 additions and 0 deletions
|
@ -174,6 +174,8 @@ function buildMutePatterns(mutedWords: (string | string[])[] | undefined): RegEx
|
||||||
let flags: string;
|
let flags: string;
|
||||||
let patterns: string[];
|
let patterns: string[];
|
||||||
|
|
||||||
|
// Translate the pattern, which can be a raw string or a regular expression.
|
||||||
|
// For unknown reasons, raw strings are expressed as an array and expressions are plain strings.
|
||||||
if (!mute) {
|
if (!mute) {
|
||||||
continue;
|
continue;
|
||||||
} else if (Array.isArray(mute)) {
|
} else if (Array.isArray(mute)) {
|
||||||
|
@ -189,6 +191,7 @@ function buildMutePatterns(mutedWords: (string | string[])[] | undefined): RegEx
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Group the patterns based on shared flags
|
||||||
let flagPatterns = patternMap.get(flags);
|
let flagPatterns = patternMap.get(flags);
|
||||||
if (!flagPatterns) {
|
if (!flagPatterns) {
|
||||||
flagPatterns = new Set<string>();
|
flagPatterns = new Set<string>();
|
||||||
|
@ -200,6 +203,7 @@ function buildMutePatterns(mutedWords: (string | string[])[] | undefined): RegEx
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Parse all the patterns into regular expressions
|
||||||
return Array
|
return Array
|
||||||
.from(patternMap)
|
.from(patternMap)
|
||||||
.map(([flag, patterns]) => {
|
.map(([flag, patterns]) => {
|
||||||
|
|
Loading…
Reference in a new issue