import { MapFnOrValue } from '../common' ; import { mapUnmatched } from '../match-execution' ; import { isMatched , TrackedEither } from '../match-tracking' ; import { MatchTester } from './types' ; description param tracker param rhs param mapOrVal internal export const matchValueTester = < TIn , TOut > ( tracker , rhs , mapOrVal ) => { if ( isMatched ( tracker ) ) return tracker ; const isObject = ( arg ) : arg is object => typeof arg === 'object' && arg !== null ; const structureMatches = ( left , right ) : boolean => isObject ( left ) && isObject ( right ) && Object . entries ( right ) . every ( ( [ k , v ] ) => k in left && left [ k as keyof TIn ] === v ) ; if ( structureMatches ( tracker . val , rhs ) ) { return mapUnmatched ( tracker , mapOrVal ) ; } if ( tracker . val === rhs ) return mapUnmatched ( tracker , mapOrVal ) ; return tracker ; } ;