Skip to content

v2.2.2

Compare
Choose a tag to compare
@gvergnaud gvergnaud released this 03 Mar 08:47

Support for multiple patterns

You can now provide up to 5 patterns to .with(), and the code branch will be chosen if your input matches one of these patterns.

Example:

match<Country>('France')
      .exhaustive()
      // if it matches one of these patterns
      .with('France', 'Germany', 'Spain', () => 'Europe')
      .with('USA', () => 'America')
      .run();

    match<Country>('France')
      .exhaustive()
      .with('Germany', 'Spain', () => 'Europe')
      .with('USA', () => 'America')
      // doesn't compile! 'France' is missing
      .run();