summaryrefslogtreecommitdiff
path: root/ext/bg/js/util.js
diff options
context:
space:
mode:
authorAlex Yatskov <alex@foosoft.net>2016-10-21 20:08:16 -0700
committerAlex Yatskov <alex@foosoft.net>2016-10-21 20:08:16 -0700
commit25a8f4fb6820cbd4be9286c85a00165ce01c0704 (patch)
tree5a4dc95e0753488e145014c6029958416552701c /ext/bg/js/util.js
parent3962a9cb1968c1f5610cef1cb515ab7a0f8caa2d (diff)
Cleanup
Diffstat (limited to 'ext/bg/js/util.js')
-rw-r--r--ext/bg/js/util.js18
1 files changed, 13 insertions, 5 deletions
diff --git a/ext/bg/js/util.js b/ext/bg/js/util.js
index 1e033eef..f10e4291 100644
--- a/ext/bg/js/util.js
+++ b/ext/bg/js/util.js
@@ -30,6 +30,19 @@ function kanjiLinks(options) {
return result;
}
+function isKanji(c) {
+ const code = c.charCodeAt(0);
+ return code >= 0x4e00 && code < 0x9fb0 || code >= 0x3400 && code < 0x4dc0;
+}
+
+function promiseCallback(promise, callback) {
+ return promise.then(result => {
+ callback({result});
+ }).catch(error => {
+ callback({error});
+ });
+}
+
function loadJson(url) {
return new Promise((resolve, reject) => {
const xhr = new XMLHttpRequest();
@@ -39,11 +52,6 @@ function loadJson(url) {
});
}
-function isKanji(c) {
- const code = c.charCodeAt(0);
- return code >= 0x4e00 && code < 0x9fb0 || code >= 0x3400 && code < 0x4dc0;
-}
-
function sortTags(tags) {
return tags.sort((v1, v2) => {
const order1 = v1.order;