diff options
Diffstat (limited to 'ext/bg/js/util.js')
-rw-r--r-- | ext/bg/js/util.js | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/ext/bg/js/util.js b/ext/bg/js/util.js index f44582eb..9a3a2a3e 100644 --- a/ext/bg/js/util.js +++ b/ext/bg/js/util.js @@ -26,6 +26,32 @@ function utilIsolate(data) { return JSON.parse(JSON.stringify(data)); } +function utilSetEqual(setA, setB) { + if (setA.size !== setB.size) { + return false; + } + + for (const value of setA) { + if (!setB.has(value)) { + return false; + } + } + + return true; +} + +function utilSetIntersection(setA, setB) { + return new Set( + [...setA].filter(value => setB.has(value)) + ); +} + +function utilSetDifference(setA, setB) { + return new Set( + [...setA].filter(value => !setB.has(value)) + ); +} + function utilBackend() { return chrome.extension.getBackgroundPage().yomichan_backend; } |