mirror of
https://github.com/DominikDoom/a1111-sd-webui-tagcomplete.git
synced 2026-03-02 11:50:24 +00:00
Sliding window search, fix double replacement
This commit is contained in:
@@ -89,6 +89,14 @@ function difference(a, b) {
|
||||
)].reduce((acc, [v, count]) => acc.concat(Array(Math.abs(count)).fill(v)), []);
|
||||
}
|
||||
|
||||
// Sliding window function to get possible combination groups of an array
|
||||
function toWindows(inputArray, size) {
|
||||
return Array.from(
|
||||
{length: inputArray.length - (size - 1)}, //get the appropriate length
|
||||
(_, index) => inputArray.slice(index, index+size) //create the windows
|
||||
)
|
||||
}
|
||||
|
||||
function escapeRegExp(string) {
|
||||
return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); // $& means the whole matched string
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user