« get me outta code hell

data: Artwork: inspect.custom - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/data
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2025-04-06 17:30:50 -0300
committer(quasar) nebula <qznebula@protonmail.com>2025-04-10 16:02:40 -0300
commit10f0b2307639d32f3fd8cdd89ee10da633eb8c07 (patch)
tree117c1484e81a02ac5b8557b0fcec4a77eb507ea3 /src/data
parentadc8167190ce173c4389d6e398548fee5e384b54 (diff)
data: Artwork: inspect.custom
Diffstat (limited to 'src/data')
-rw-r--r--src/data/things/artwork.js26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/data/things/artwork.js b/src/data/things/artwork.js
index 2e8936a4..66a3c1ae 100644
--- a/src/data/things/artwork.js
+++ b/src/data/things/artwork.js
@@ -1,3 +1,5 @@
+import {inspect} from 'node:util';
+
 import {input} from '#composite';
 import Thing from '#thing';
 import {isContributionList, isDate, isFileExtension, validateReferenceList}
@@ -188,4 +190,28 @@ export class Artwork extends Thing {
 
     return this.thing.getOwnArtworkPath(this);
   }
+
+  [inspect.custom](depth, options, inspect) {
+    const parts = [];
+
+    parts.push(Thing.prototype[inspect.custom].apply(this));
+
+    if (this.thing) {
+      if (depth >= 0) {
+        const newOptions = {
+          ...options,
+          depth:
+            (options.depth === null
+              ? null
+              : options.depth - 1),
+        };
+
+        parts.push(` for ${inspect(this.thing, newOptions)}`);
+      } else {
+        parts.push(` for ${colors.blue(Thing.getReference(this.thing))}`);
+      }
+    }
+
+    return parts.join('');
+  }
 }