From 7f94b714cdac8b19334f1e06040581c65fb81216 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Tue, 4 Apr 2023 13:51:33 -0300 Subject: infra: new 'postprocess' option in quickEvaluate --- src/content-function.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) 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; + } } -- cgit 1.3.0-6-gf8a5