« get me outta code hell

content: generateArtistInfoPage: artwork contributions - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/util
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2023-06-02 12:42:26 -0300
committer(quasar) nebula <qznebula@protonmail.com>2023-06-02 12:45:09 -0300
commit5981f69fac3e0d303425b8df125cd9e705c9eea8 (patch)
tree5dd75430f2642a5bf52b455e0d034a5ff8074937 /src/util
parent8c0e7e47cc0a44b8c37bda8b85029420a99d0098 (diff)
content: generateArtistInfoPage: artwork contributions
This actually covers the foundations for other types of contribs
too. It's hopefully a fair bit cleaner and easier to follow than
the previous data processing for this page!
Diffstat (limited to 'src/util')
-rw-r--r--src/util/sugar.js8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/util/sugar.js b/src/util/sugar.js
index 0362e327..6ab70bc6 100644
--- a/src/util/sugar.js
+++ b/src/util/sugar.js
@@ -82,6 +82,14 @@ export const compareArrays = (arr1, arr2, {checkOrder = true} = {}) =>
 export const withEntries = (obj, fn) =>
   Object.fromEntries(fn(Object.entries(obj)));
 
+export function filterProperties(obj, properties) {
+  const set = new Set(properties);
+  return Object.fromEntries(
+    Object
+      .entries(obj)
+      .filter(([key]) => set.has(key)));
+}
+
 export function queue(array, max = 50) {
   if (max === 0) {
     return array.map((fn) => fn());