@ryandur/sand
    Preparing search index...

    Function matchOn

    • Type Parameters

      • MATCH extends string | number

      Parameters

      Returns <VALUE>(
          on: MATCH | null | undefined,
          cases: Record<MATCH, () => VALUE>,
      ) => Maybe<VALUE>

      test for matchOn

      Example:

      enum Thing {
      One = 'One',
      Two = 'Two',
      Three = 'Three'
      }

      const matchThings = 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"