summaryrefslogtreecommitdiff
path: root/tools/parse-layout.js
diff options
context:
space:
mode:
Diffstat (limited to 'tools/parse-layout.js')
-rw-r--r--tools/parse-layout.js22
1 files changed, 22 insertions, 0 deletions
diff --git a/tools/parse-layout.js b/tools/parse-layout.js
index f2443fd..b389669 100644
--- a/tools/parse-layout.js
+++ b/tools/parse-layout.js
@@ -430,6 +430,28 @@ remap_to_range(sets.map)
remap_to_range(sets.suit)
remap_to_range(sets.country)
+function object_group_by(items, callback) {
+ let groups = {}
+ if (typeof callback === "function") {
+ for (let item of items) {
+ let key = callback(item)
+ if (key in groups)
+ groups[key].push(item)
+ else
+ groups[key] = [ item ]
+ }
+ } else {
+ for (let item of items) {
+ let key = item[callback]
+ if (key in groups)
+ groups[key].push(item)
+ else
+ groups[key] = [ item ]
+ }
+ }
+ return groups
+}
+
delete sets.type.city
sets.cities = arrays