« get me outta code hell

data steps: annotate content function names - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/content-function.js
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2023-03-18 19:41:32 -0300
committer(quasar) nebula <qznebula@protonmail.com>2023-03-18 20:15:21 -0300
commit4f0d935f1dec0cece23ac661b02486f095b5ee94 (patch)
tree5ecb22838d56c747c65793b49bac51565b4ce17f /src/content-function.js
parent82f1d4de61b3660e07353f44e6125ced019b18ad (diff)
data steps: annotate content function names
Diffstat (limited to 'src/content-function.js')
-rw-r--r--src/content-function.js16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/content-function.js b/src/content-function.js
index 5138379..654a294 100644
--- a/src/content-function.js
+++ b/src/content-function.js
@@ -1,4 +1,4 @@
-import {empty} from './util/sugar.js';
+import {annotateFunction, empty} from './util/sugar.js';
 
 export default function contentFunction({
   contentDependencies = [],
@@ -54,6 +54,7 @@ export function expectDependencies({
       throw new Error(`Generate invalidated because unfulfilled dependencies provided: ${invalidatingDependencyKeys.join(', ')}`);
     };
 
+    annotateFunction(wrappedGenerate, {name: generate, trait: 'invalidated'});
     wrappedGenerate.fulfilled ??= false;
   }
 
@@ -62,17 +63,19 @@ export function expectDependencies({
       return generate(data, fulfilledDependencies);
     };
 
+    annotateFunction(wrappedGenerate, {name: generate, trait: 'fulfilled'});
+    wrappedGenerate.fulfilled ??= true;
+
     wrappedGenerate.fulfill = function() {
       throw new Error(`All dependencies already fulfilled`);
     };
-
-    wrappedGenerate.fulfilled ??= true;
   }
 
   wrappedGenerate ??= function() {
     throw new Error(`Dependencies still needed: ${missingContentDependencyKeys.concat(missingExtraDependencyKeys).join(', ')}`);
   };
 
+  annotateFunction(wrappedGenerate, {name: generate, trait: 'unfulfilled'});
   wrappedGenerate.fulfilled ??= false;
   wrappedGenerate[contentFunction.identifyingSymbol] = true;
 
@@ -84,6 +87,7 @@ export function expectDependencies({
         throw new Error(`Expected call to this dependency's .data()`);
       };
 
+      annotateFunction(wrappedGenerate, {name: fulfilledDependencies[key], description: 'data only'});
       wrappedDependency.data = fulfilledDependencies[key].data;
       dataDependencies[key] = wrappedDependency;
     }
@@ -91,13 +95,17 @@ export function expectDependencies({
     wrappedGenerate.data = function(...args) {
       return data(...args, dataDependencies);
     };
+
+    annotateFunction(wrappedGenerate.data, {name: data, trait: 'fulfilled'});
   }
 
   wrappedGenerate.data ??= function() {
     throw new Error(`Dependencies still needed: ${missingContentDependencyKeys.join(', ')}`);
   };
 
-  wrappedGenerate.fulfill ??= function(dependencies) {
+  annotateFunction(wrappedGenerate.data, {name: data, trait: 'unfulfilled'});
+
+  wrappedGenerate.fulfill ??= function fulfill(dependencies) {
     return expectDependencies({
       generate,
       data,