« get me outta code hell

finish up cosmetic style changes - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/util/wiki-data.js
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2022-11-26 23:44:08 -0400
committer(quasar) nebula <qznebula@protonmail.com>2022-11-26 23:44:08 -0400
commit003f594f6348b55109dd66416e75fcc2a88faade (patch)
treeb4cb05ed4e145e604356786a1d98926040fe5ff0 /src/util/wiki-data.js
parent768927503b5948b846b9a6cddf4b788ca9792e8c (diff)
finish up cosmetic style changes
Diffstat (limited to 'src/util/wiki-data.js')
-rw-r--r--src/util/wiki-data.js54
1 files changed, 26 insertions, 28 deletions
diff --git a/src/util/wiki-data.js b/src/util/wiki-data.js
index b0b0b2e0..7d2cfa9f 100644
--- a/src/util/wiki-data.js
+++ b/src/util/wiki-data.js
@@ -1,5 +1,3 @@
-/** @format */
-
 // Utility functions for interacting with wiki data.
 
 import {empty} from './sugar.js';
@@ -144,10 +142,9 @@ export function normalizeName(s) {
 // ...trackData]), because the initial sort places albums before tracks - and
 // sortByDirectory will handle the rest, given all directories are unique
 // except when album and track directories overlap with each other.
-export function sortByDirectory(
-  data,
-  {getDirectory = (o) => o.directory} = {}
-) {
+export function sortByDirectory(data, {
+  getDirectory = (o) => o.directory,
+} = {}) {
   return data.sort((a, b) => {
     const ad = getDirectory(a);
     const bd = getDirectory(b);
@@ -155,7 +152,9 @@ export function sortByDirectory(
   });
 }
 
-export function sortByName(data, {getName = (o) => o.name} = {}) {
+export function sortByName(data, {
+  getName = (o) => o.name,
+} = {}) {
   const nameMap = new Map();
   const normalizedNameMap = new Map();
   for (const o of data) {
@@ -178,7 +177,9 @@ export function sortByName(data, {getName = (o) => o.name} = {}) {
   });
 }
 
-export function sortByDate(data, {getDate = (o) => o.date} = {}) {
+export function sortByDate(data, {
+  getDate = (o) => o.date,
+} = {}) {
   return data.sort((a, b) => {
     const ad = getDate(a);
     const bd = getDate(b);
@@ -269,7 +270,10 @@ export function sortByConditions(data, conditions) {
 // Expects thing properties:
 //  * directory (or override getDirectory)
 //  * name (or override getName)
-export function sortAlphabetically(data, {getDirectory, getName} = {}) {
+export function sortAlphabetically(data, {
+  getDirectory,
+  getName,
+} = {}) {
   sortByDirectory(data, {getDirectory});
   sortByName(data, {getName});
   return data;
@@ -279,10 +283,11 @@ export function sortAlphabetically(data, {getDirectory, getName} = {}) {
 //  * directory (or override getDirectory)
 //  * name (or override getName)
 //  * date (or override getDate)
-export function sortChronologically(
-  data,
-  {getDirectory, getName, getDate} = {}
-) {
+export function sortChronologically(data, {
+  getDirectory,
+  getName,
+  getDate,
+} = {}) {
   sortAlphabetically(data, {getDirectory, getName});
   sortByDate(data, {getDate});
   return data;
@@ -296,7 +301,9 @@ export function sortChronologically(
 // release date but can be overridden) above all else.
 //
 // This function also works for data lists which contain only tracks.
-export function sortAlbumsTracksChronologically(data, {getDate} = {}) {
+export function sortAlbumsTracksChronologically(data, {
+  getDate,
+} = {}) {
   // Sort albums before tracks...
   sortByConditions(data, [(t) => t.album === undefined]);
 
@@ -320,9 +327,8 @@ export function sortAlbumsTracksChronologically(data, {getDate} = {}) {
 // Specific data utilities
 
 export function filterAlbumsByCommentary(albums) {
-  return albums.filter((album) =>
-    [album, ...album.tracks].some((x) => x.commentary)
-  );
+  return albums
+    .filter((album) => [album, ...album.tracks].some((x) => x.commentary));
 }
 
 export function getAlbumCover(album, {to}) {
@@ -387,12 +393,7 @@ export function getTrackCover(track, {to}) {
   if (!track.hasCoverArt) {
     return getAlbumCover(track.album, {to});
   } else {
-    return to(
-      'media.trackCover',
-      track.album.directory,
-      track.directory,
-      track.coverArtFileExtension
-    );
+    return to('media.trackCover', track.album.directory, track.directory, track.coverArtFileExtension);
   }
 }
 
@@ -455,11 +456,7 @@ export function getNewAdditions(numAlbums, {wikiData}) {
     const currentDate = sortedAlbums[i].dateAddedToWiki;
     const groupMap = new Map();
     const groupArray = [];
-    for (
-      let album;
-      (album = sortedAlbums[i]) && +album.dateAddedToWiki === +currentDate;
-      i++
-    ) {
+    for (let album; (album = sortedAlbums[i]) && +album.dateAddedToWiki === +currentDate; i++) {
       const primaryGroup = album.groups[0];
       if (groupMap.has(primaryGroup)) {
         groupMap.get(primaryGroup).push(album);
@@ -510,6 +507,7 @@ export function getNewReleases(numReleases, {wikiData}) {
   const latestFirst = albumData
     .filter((album) => album.isListedOnHomepage)
     .reverse();
+
   const majorReleases = latestFirst.filter((album) => album.isMajorRelease);
   majorReleases.splice(1);