summaryrefslogtreecommitdiff
path: root/ext/bg/js/util.js
diff options
context:
space:
mode:
authorsiikamiika <siikamiika@users.noreply.github.com>2017-10-03 07:20:02 +0300
committersiikamiika <siikamiika@users.noreply.github.com>2017-10-03 07:20:02 +0300
commit69ad4a7c9b1f859733909a75534e2005a9f56178 (patch)
tree93cec595a2e8183a95fc362b5551e2e68cefc9d8 /ext/bg/js/util.js
parent3b664dd908b94e1306a211e7c8b9cde74694c018 (diff)
merged mode: implement missing stuff, refactoring
- use correct tags - indicate popular and rare terms - indicate definitions restricted to specific terms - frequencies (Innocent Corpus)
Diffstat (limited to 'ext/bg/js/util.js')
-rw-r--r--ext/bg/js/util.js26
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;
}