enumThing { One = 'One', Two = 'Two', Three = 'Three' }
constmatchThings = matchOn(Object.values(Thing));
matchThings(Thing.Two, { [Thing.One]: () =>'I am one', [Thing.Two]: () =>'I am two', [Thing.Three]: () =>'I am three', }).orElse('none of the above'); // produces: "I am two"
matchThings(undefined, { [Thing.One]: () =>'I am one', [Thing.Two]: () =>'I am two', [Thing.Three]: () =>'I am three', }).orElse('none of the above'); // produces: "none of the above"
See
test for matchOn
Example: