(
resolve,
paths,
matches,
triggerAnyVals = ''
)
| 1159 | } |
| 1160 | |
| 1161 | export function addAllResolvedFromOutputs( |
| 1162 | resolve, |
| 1163 | paths, |
| 1164 | matches, |
| 1165 | triggerAnyVals = '' |
| 1166 | ) { |
| 1167 | return callback => { |
| 1168 | const {matchKeys, firstSingleOutput, outputs} = callback; |
| 1169 | if (matchKeys.length) { |
| 1170 | const singleOutPattern = outputs[firstSingleOutput]; |
| 1171 | if (singleOutPattern) { |
| 1172 | addResolvedFromOutputs( |
| 1173 | callback, |
| 1174 | singleOutPattern, |
| 1175 | resolve(paths)(singleOutPattern), |
| 1176 | matches |
| 1177 | ); |
| 1178 | } else { |
| 1179 | /* |
| 1180 | * If every output has ALL we need to reduce resolved set |
| 1181 | * to one item per combination of MATCH values. |
| 1182 | * That will give one result per callback invocation. |
| 1183 | */ |
| 1184 | const anySeen = {}; |
| 1185 | outputs.forEach(outPattern => { |
| 1186 | const outSet = resolve(paths)(outPattern).filter(i => { |
| 1187 | const matchStr = JSON.stringify(props(matchKeys, i.id)); |
| 1188 | if (!anySeen[matchStr]) { |
| 1189 | anySeen[matchStr] = 1; |
| 1190 | return true; |
| 1191 | } |
| 1192 | return false; |
| 1193 | }); |
| 1194 | addResolvedFromOutputs( |
| 1195 | callback, |
| 1196 | outPattern, |
| 1197 | outSet, |
| 1198 | matches |
| 1199 | ); |
| 1200 | }); |
| 1201 | } |
| 1202 | } else { |
| 1203 | // Outputs have no MATCH keys (fixed-id outputs or no output). |
| 1204 | // Fall back to the triggering input's MATCH values so that |
| 1205 | // separate MATCH triggers produce distinct resolvedIds and |
| 1206 | // aren't deduplicated into a single firing. See issue #2462. |
| 1207 | const cb = makeResolvedCallback(callback, resolve, triggerAnyVals); |
| 1208 | matches.push(cb); |
| 1209 | } |
| 1210 | }; |
| 1211 | } |
| 1212 | |
| 1213 | /* |
| 1214 | * For a given id and prop find all callbacks it's an input of. |
no test coverage detected
searching dependent graphs…