From 5b16090a206db99a266fcc006921782b37f8d1a0 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Sat, 11 Jan 2025 13:30:05 -0400 Subject: data: general withReverse{*}List logic tidying --- .../wiki-data/withReverseSingleReferenceList.js | 32 +++++++++++----------- 1 file changed, 16 insertions(+), 16 deletions(-) (limited to 'src/data/composite/wiki-data/withReverseSingleReferenceList.js') diff --git a/src/data/composite/wiki-data/withReverseSingleReferenceList.js b/src/data/composite/wiki-data/withReverseSingleReferenceList.js index dd97dc66..569e9ba0 100644 --- a/src/data/composite/wiki-data/withReverseSingleReferenceList.js +++ b/src/data/composite/wiki-data/withReverseSingleReferenceList.js @@ -6,7 +6,8 @@ import withReverseList_template from './helpers/withReverseList-template.js'; import {input} from '#composite'; -import {withMappedList} from '#composite/data'; +import {withAvailabilityFilter} from '#composite/control-flow'; +import {withMappedList, withPropertyFromList} from '#composite/data'; export default withReverseList_template({ annotation: `withReverseSingleReferenceList`, @@ -25,24 +26,23 @@ export default withReverseList_template({ }), }, + withPropertyFromList({ + list: '#referencingThings', + property: input('ref'), + }).outputs({ + '#values': '#individualReferencedThings', + }), + + withAvailabilityFilter({ + from: '#individualReferencedThings', + }), + // This map wraps each referenced thing in a single-item array. // Each referencing thing references exactly one thing, if any. - { - dependencies: [input('ref')], - compute: (continuation, { - [input('ref')]: ref, - }) => continuation({ - ['#singleReferenceMap']: - thing => - (thing[ref] - ? [thing[ref]] - : []), - }), - }, - withMappedList({ - list: '#referencingThings', - map: '#singleReferenceMap', + list: '#individualReferencedThings', + filter: '#availabilityFilter', + map: input.value(thing => [thing]), }).outputs({ '#mappedList': '#referencedThings', }), -- cgit 1.3.0-6-gf8a5