Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 | 22x 22x 105x 105x | import S from './sanitised.js'
import type Sid from './sanitised-identifier.js'
/** @returns sanitised value as is, otherwise falls back to provided sanitation function. */
export const fallback =
<T>(x: T, f: (_: Exclude<T, S | Sid>) => undefined | S): undefined | S =>
x instanceof S ?
x :
f(x as Exclude<T, S | Sid>)
export default fallback
|