Returns a corresponding expression based on a matching value of an expression provided. Uses isEqual
under the hood.
function caseEquals<T = any, U = any>(
value: T,
...casesAndDefault: [...c: [T, U][], U]
)
// Example:
const widthByHeight = round(1920 / 1080, 0.01) // 1.78
const apectRatio = caseEquals(
widthByHeight,
[1.78, "16:9"],
[1.5, "3:2"],
[1.33, "4:3"],
[1, "1:1"],
"Uncommon aspect ratio"
)
//=> "16:9"