diff options
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 |
commit | 7f94b714cdac8b19334f1e06040581c65fb81216 (patch) | |
tree | a887248ce8bda5255ea03bc354b9a96e73c7112e | |
parent | 762be9d8078a2fd19a460b7172129a9575974f1f (diff) |
infra: new 'postprocess' option in quickEvaluate
-rw-r--r-- | src/content-function.js | 10 |
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; + } } |