import { mapUnmatched } from '../match-execution' ; import { isUnmatched , TrackedEither } from '../match-tracking' ; import { isCtorInvokedWithoutNewError , isFn , MapFnOrValue } from '../common' ; import { MatchTester } from './types' ; description param tracker param fn param transformer internal export const matchFnTester = < TIn , TOut > ( tracker , fn , transformer ) => { if ( isUnmatched ( tracker ) && isFn ( fn ) ) { let fnReturn ; try { fnReturn = fn ( tracker . val ) ; } catch ( e ) { if ( ! isCtorInvokedWithoutNewError ( e ) ) { throw e ; } } if ( fnReturn === true || fnReturn === tracker . val ) { return mapUnmatched ( tracker , transformer ) ; } } return tracker ; } ;