Checks if `found` is equal to `desired` and returns the appropriate cost. * If desired is not given (undefined) then `skipCost` is returned. * If `found` is equal to `desired` then `0` is returned, otherwise `mismatchCost`.
(
desired: T | undefined,
found: T,
mismatchCost: number,
skipCost: number
)
| 44 | * If `found` is equal to `desired` then `0` is returned, otherwise `mismatchCost`. |
| 45 | */ |
| 46 | function matchingCost<T>( |
| 47 | desired: T | undefined, |
| 48 | found: T, |
| 49 | mismatchCost: number, |
| 50 | skipCost: number |
| 51 | ) { |
| 52 | if (desired !== undefined) { |
| 53 | return found === desired ? 0 : mismatchCost; |
| 54 | } else { |
| 55 | return skipCost; |
| 56 | } |
| 57 | } |
| 58 | |
| 59 | const INF_COST = 100000; |
| 60 |
no outgoing calls
no test coverage detected