diff options
author | Tor Andersson <tor@ccxvii.net> | 2024-05-30 22:04:34 +0200 |
---|---|---|
committer | Tor Andersson <tor@ccxvii.net> | 2024-05-30 22:04:34 +0200 |
commit | e571d8717bd479fabbd4017e55394ad6f1870360 (patch) | |
tree | 23455d05ac0b10333a4a9371d09facee89446b7b /tools | |
parent | d08d720730fd0b2517a864c4ea308b145a69da72 (diff) | |
download | maria-e571d8717bd479fabbd4017e55394ad6f1870360.tar.gz |
lout
Diffstat (limited to 'tools')
-rw-r--r-- | tools/parse-layout.js | 22 |
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 |