« get me outta code hell

find: findMixedHelper directory internals - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2024-11-14 19:04:37 -0400
committer(quasar) nebula <qznebula@protonmail.com>2024-11-15 20:40:13 -0400
commit042f60f47660a4354cad4d7a80c5beaf86c9cb62 (patch)
tree617c2f9a9f73036a8b1cdcfd4aac61dfee5ab6d5 /src
parent3c859e00f571741823acd3c1ed017f594aee478b (diff)
find: findMixedHelper directory internals
Diffstat (limited to 'src')
-rw-r--r--src/find.js24
1 files changed, 21 insertions, 3 deletions
diff --git a/src/find.js b/src/find.js
index 157597c2..2f1db9df 100644
--- a/src/find.js
+++ b/src/find.js
@@ -1,7 +1,7 @@
 import {inspect} from 'node:util';
 
 import {colors, logWarn} from '#cli';
-import {compareObjects, typeAppearance} from '#sugar';
+import {compareObjects, stitchArrays, typeAppearance} from '#sugar';
 import thingConstructors from '#things';
 import {isFunction, validateArrayItems} from '#validators';
 
@@ -347,9 +347,27 @@ function findMixedHelper(config) {
       });
     }
 
+    const byDirectory =
+      Object.fromEntries(
+        stitchArrays({
+          referenceType: keys,
+          spec: specs,
+        }).map(({referenceType, spec}) => [
+            referenceType,
+            processAvailableMatchesByDirectory(data, spec).results,
+          ]));
+
     return matchHelper(fullRef, mode, {
-      matchByDirectory:
-        () => null, /* TODO: Do something */
+      matchByDirectory: (referenceType, directory) => {
+        if (!keys.includes(referenceType)) {
+          return oopsWrongReferenceType(mode, {
+            referenceType,
+            referenceTypes: keys,
+          });
+        }
+
+        return byDirectory[referenceType][directory];
+      },
 
       matchByName:
         prepareMatchByName(mode, {