« get me outta code hell

infra: new 'postprocess' option in quickEvaluate - 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>2023-04-04 13:51:33 -0300
committer(quasar) nebula <qznebula@protonmail.com>2023-04-04 13:51:33 -0300
commit7f94b714cdac8b19334f1e06040581c65fb81216 (patch)
treea887248ce8bda5255ea03bc354b9a96e73c7112e /src
parent762be9d8078a2fd19a460b7172129a9575974f1f (diff)
infra: new 'postprocess' option in quickEvaluate
Diffstat (limited to 'src')
-rw-r--r--src/content-function.js10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/content-function.js b/src/content-function.js
index 30e0ccc3..53cb13cf 100644
--- a/src/content-function.js
+++ b/src/content-function.js
@@ -339,6 +339,7 @@ export function quickEvaluate({
   name,
   args = [],
   multiple = null,
+  postprocess = null,
 }) {
   if (multiple !== null) {
     return multiple.map(opts =>
@@ -349,6 +350,7 @@ export function quickEvaluate({
         ...opts,
         name: opts.name ?? name,
         args: opts.args ?? args,
+        postprocess: opts.postprocess ?? postprocess,
       }));
   }
 
@@ -436,5 +438,11 @@ export function quickEvaluate({
     slotResults[slot] = runContentFunction(flatRelationSlots[slot]);
   }
 
-  return runContentFunction(root);
+  const topLevelResult = runContentFunction(root);
+
+  if (postprocess !== null) {
+    return postprocess(topLevelResult);
+  } else {
+    return topLevelResult;
+  }
 }