From 36e2006bc9a24918ba886d9cef28d6288bf01c40 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Sun, 9 Jun 2024 17:01:36 -0300 Subject: content: generateTrackListDividedByGroups: inline util function --- .../generateTrackListDividedByGroups.js | 22 ++++++++++++++++++++- src/content/util/groupTracksByGroup.js | 23 ---------------------- 2 files changed, 21 insertions(+), 24 deletions(-) delete mode 100644 src/content/util/groupTracksByGroup.js diff --git a/src/content/dependencies/generateTrackListDividedByGroups.js b/src/content/dependencies/generateTrackListDividedByGroups.js index a9326205..5ab53068 100644 --- a/src/content/dependencies/generateTrackListDividedByGroups.js +++ b/src/content/dependencies/generateTrackListDividedByGroups.js @@ -1,6 +1,26 @@ import {empty, stitchArrays} from '#sugar'; -import groupTracksByGroup from '../util/groupTracksByGroup.js'; +function groupTracksByGroup(tracks, groups) { + const lists = new Map(groups.map(group => [group, []])); + lists.set('other', []); + + for (const track of tracks) { + const group = groups.find(group => group.albums.includes(track.album)); + if (group) { + lists.get(group).push(track); + } else { + lists.get('other').push(track); + } + } + + for (const [key, tracks] of lists.entries()) { + if (empty(tracks)) { + lists.delete(key); + } + } + + return lists; +} export default { contentDependencies: [ diff --git a/src/content/util/groupTracksByGroup.js b/src/content/util/groupTracksByGroup.js deleted file mode 100644 index 4e189007..00000000 --- a/src/content/util/groupTracksByGroup.js +++ /dev/null @@ -1,23 +0,0 @@ -import {empty} from '#sugar'; - -export default function groupTracksByGroup(tracks, groups) { - const lists = new Map(groups.map(group => [group, []])); - lists.set('other', []); - - for (const track of tracks) { - const group = groups.find(group => group.albums.includes(track.album)); - if (group) { - lists.get(group).push(track); - } else { - lists.get('other').push(track); - } - } - - for (const [key, tracks] of lists.entries()) { - if (empty(tracks)) { - lists.delete(key); - } - } - - return lists; -} -- cgit 1.3.0-6-gf8a5