hunk.code_window:       )
       );
     });
     it('should match a value from a pattern with the state (compound)', () => {
       const simpleState = State.from({ a: 'b' }, undefined);
       assert.ok(
  
hunk.labels: keep keep keep add keep keep keep keep
hunk.after_edit:   it('should match a value from a pattern with the state value', () => {
       assert.ok(
         matchState(
           'a',
           [['b', () => false], ['a', () => true], [{ a: 'b' }, () => false]],
           _ => false
         )
       );
     });
  
hunk.file_path: test/match.test.ts
hunk.type: add
file: import { State } from './State';
  import { StateValue, EventObject } from './types';
  
  export type ValueFromStateGetter<T, TContext, TEvent extends EventObject> = (
    state: State<TContext, TEvent>
  ) => T;
  
  export type StatePatternTuple<T, TContext, TEvent extends EventObject> = [
    StateValue,
    ValueFromStateGetter<T, TContext, TEvent>
  ];
  
  export function matchState<T, TContext, TEvent extends EventObject>(
    state: State<TContext, TEvent>,
    patterns: Array<StatePatternTuple<T, TContext, TEvent>>,
    defaultValue: ValueFromStateGetter<T, TContext, TEvent>
  ): T {
    for (const [stateValue, getValue] of patterns) {
      if (state.matches(stateValue)) {
        return getValue(state);
      }
    }
  
    return defaultValue(state);
  }
  