aboutsummaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
Diffstat (limited to 'common')
-rw-r--r--common/broadcast.js4
-rw-r--r--common/entities.js4
-rw-r--r--common/indexeddb.js2
-rw-r--r--common/patterns_query_tree.js2
4 files changed, 8 insertions, 4 deletions
diff --git a/common/broadcast.js b/common/broadcast.js
index 4dcac2b..4fc5237 100644
--- a/common/broadcast.js
+++ b/common/broadcast.js
@@ -46,6 +46,7 @@
function sender_connection()
{
return {
+ type: "sender",
port: connect_to_background("broadcast_send")
};
}
@@ -92,6 +93,7 @@ function flush(sender_conn)
function listener_connection(cb)
{
const conn = {
+ type: "listener",
port: connect_to_background("broadcast_listen")
};
@@ -115,6 +117,8 @@ function unsubscribe(listener_conn, channel_name)
function close(conn)
{
+ if (conn.type === "sender")
+ flush(conn);
conn.port.disconnect();
}
#EXPORT close
diff --git a/common/entities.js b/common/entities.js
index 3ccbf04..96de5cb 100644
--- a/common/entities.js
+++ b/common/entities.js
@@ -74,7 +74,7 @@ function item_id_string(...args) {
#EXPORT item_id_string
/* vers should be an array of comparable values. Return the greatest one. */
-const max = vals => Array.reduce(vals, (v1, v2) => v1 > v2 ? v1 : v2);
+const max = vals => vals.reduce((v1, v2) => v1 > v2 ? v1 : v2);
/*
* versioned_item should be a dict with keys being version strings and values
@@ -167,6 +167,6 @@ const version_reductor = (acc, n) => [...(n || acc.length ? [n] : []), ...acc];
*
* Returns a *new* array. Doesn't modify its argument.
*/
-const normalize_version = ver => Array.reduceRight(ver, version_reductor, []);
+const normalize_version = ver => ver.reduceRight(version_reductor, []);
#ENDIF
diff --git a/common/indexeddb.js b/common/indexeddb.js
index 271dfce..f916162 100644
--- a/common/indexeddb.js
+++ b/common/indexeddb.js
@@ -56,7 +56,7 @@ let initial_data = (
const db_version = [1, 0, 0];
const nr_reductor = ([i, s], num) => [i - 1, s + num * 1024 ** i];
-const version_nr = ver => Array.reduce(ver.slice(0, 3), nr_reductor, [2, 0])[1];
+const version_nr = ver => ver.slice(0, 3).reduce(nr_reductor, [2, 0])[1];
const stores = [
["files", {keyPath: "hash_key"}],
diff --git a/common/patterns_query_tree.js b/common/patterns_query_tree.js
index ec1d989..ea3607e 100644
--- a/common/patterns_query_tree.js
+++ b/common/patterns_query_tree.js
@@ -68,7 +68,7 @@ function is_empty_node(tree_node) {
return false;
}
- if (Array.reduce(tree_node.wildcard_matches, (a, b) => b && a !== null, 1))
+ if (tree_node.wildcard_matches.reduce((a, b) => b && a !== null, 1))
return false;
return tree_node.literal_match === null;