summaryrefslogtreecommitdiff
path: root/ext/bg/js/util.js
diff options
context:
space:
mode:
Diffstat (limited to 'ext/bg/js/util.js')
-rw-r--r--ext/bg/js/util.js15
1 files changed, 15 insertions, 0 deletions
diff --git a/ext/bg/js/util.js b/ext/bg/js/util.js
index 9a3a2a3e..88d96688 100644
--- a/ext/bg/js/util.js
+++ b/ext/bg/js/util.js
@@ -52,6 +52,21 @@ function utilSetDifference(setA, setB) {
);
}
+function utilStringHashCode(string) {
+ let hashCode = 0;
+
+ if (string.length === 0) {
+ return hashCode;
+ }
+
+ for (let i = 0, charCode = string.charCodeAt(i); i < string.length; i++) {
+ hashCode = ((hashCode << 5) - hashCode) + charCode;
+ hashCode |= 0;
+ }
+
+ return hashCode;
+}
+
function utilBackend() {
return chrome.extension.getBackgroundPage().yomichan_backend;
}