(
keys,
vals,
patternVals,
refKeys,
refVals,
refPatternVals
)
| 1008 | * correct matching of MATCH or ALLSMALLER between input and output items. |
| 1009 | */ |
| 1010 | export function idMatch( |
| 1011 | keys, |
| 1012 | vals, |
| 1013 | patternVals, |
| 1014 | refKeys, |
| 1015 | refVals, |
| 1016 | refPatternVals |
| 1017 | ) { |
| 1018 | for (let i = 0; i < keys.length; i++) { |
| 1019 | const val = vals[i]; |
| 1020 | const patternVal = patternVals[i]; |
| 1021 | if (patternVal.wild) { |
| 1022 | // If we have a second id, compare the wildcard values. |
| 1023 | // Without a second id, all wildcards pass at this stage. |
| 1024 | if (refKeys && patternVal !== ALL) { |
| 1025 | const refIndex = refKeys.indexOf(keys[i]); |
| 1026 | const refPatternVal = refPatternVals[refIndex]; |
| 1027 | // Sanity check. Shouldn't ever fail this, if the back end |
| 1028 | // did its job validating callbacks. |
| 1029 | // You can't resolve an input against an input, because |
| 1030 | // two ALLSMALLER's wouldn't make sense! |
| 1031 | if (patternVal === ALLSMALLER && refPatternVal === ALLSMALLER) { |
| 1032 | throw new Error( |
| 1033 | 'invalid wildcard id pair: ' + |
| 1034 | JSON.stringify({ |
| 1035 | keys, |
| 1036 | patternVals, |
| 1037 | vals, |
| 1038 | refKeys, |
| 1039 | refPatternVals, |
| 1040 | refVals |
| 1041 | }) |
| 1042 | ); |
| 1043 | } |
| 1044 | if ( |
| 1045 | idValSort(val, refVals[refIndex]) !== |
| 1046 | (patternVal === ALLSMALLER |
| 1047 | ? -1 |
| 1048 | : refPatternVal === ALLSMALLER |
| 1049 | ? 1 |
| 1050 | : 0) |
| 1051 | ) { |
| 1052 | return false; |
| 1053 | } |
| 1054 | } |
| 1055 | } else if (val !== patternVal) { |
| 1056 | return false; |
| 1057 | } |
| 1058 | } |
| 1059 | return true; |
| 1060 | } |
| 1061 | |
| 1062 | export function getAnyVals(patternVals, vals) { |
| 1063 | const matches = []; |
no test coverage detected
searching dependent graphs…