From 65ff74446f22976613caf352d42253c8c17e172d Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Sat, 16 Nov 2024 13:29:52 -0400 Subject: data: raiseResolvedReferenceList This commit also implements raiseResolvedReferenceList across the compositions which have a notFoundMode input. This causes no semantic changes at all, except that notFoundMode is no longer ignored(!!) in withResolvedContribs. --- .../wiki-data/withResolvedReferenceList.js | 53 ++++++---------------- 1 file changed, 15 insertions(+), 38 deletions(-) (limited to 'src/data/composite/wiki-data/withResolvedReferenceList.js') diff --git a/src/data/composite/wiki-data/withResolvedReferenceList.js b/src/data/composite/wiki-data/withResolvedReferenceList.js index f929d400..790a962f 100644 --- a/src/data/composite/wiki-data/withResolvedReferenceList.js +++ b/src/data/composite/wiki-data/withResolvedReferenceList.js @@ -7,11 +7,15 @@ import {input, templateCompositeFrom} from '#composite'; import {isString, validateArrayItems} from '#validators'; -import {exitWithoutDependency, raiseOutputWithoutDependency} - from '#composite/control-flow'; +import { + exitWithoutDependency, + raiseOutputWithoutDependency, + withAvailabilityFilter, +} from '#composite/control-flow'; import inputNotFoundMode from './inputNotFoundMode.js'; import inputWikiData from './inputWikiData.js'; +import raiseResolvedReferenceList from './raiseResolvedReferenceList.js'; export default templateCompositeFrom({ annotation: `withResolvedReferenceList`, @@ -56,42 +60,15 @@ export default templateCompositeFrom({ }), }, - { - dependencies: ['#matches'], - compute: (continuation, {'#matches': matches}) => - (matches.every(match => match) - ? continuation.raiseOutput({ - ['#resolvedReferenceList']: matches, - }) - : continuation()), - }, - - { - dependencies: ['#matches', input('notFoundMode')], - compute(continuation, { - ['#matches']: matches, - [input('notFoundMode')]: notFoundMode, - }) { - switch (notFoundMode) { - case 'exit': - return continuation.exit([]); - - case 'filter': - return continuation.raiseOutput({ - ['#resolvedReferenceList']: - matches.filter(match => match), - }); - - case 'null': - return continuation.raiseOutput({ - ['#resolvedReferenceList']: - matches.map(match => match ?? null), - }); + withAvailabilityFilter({ + from: '#matches', + }), - default: - throw new TypeError(`Expected notFoundMode to be exit, filter, or null`); - } - }, - }, + raiseResolvedReferenceList({ + notFoundMode: input('notFoundMode'), + results: '#matches', + filter: '#availabilityFilter', + outputs: input.value('#resolvedReferenceList'), + }), ], }); -- cgit 1.3.0-6-gf8a5