import { pickBy } from './index' ; type Maybe < T > = undefined | T ; const isMaybeDefined = < T > ( maybeT ) : maybeT is T => maybeT !== undefined ; /** Takes a dictionary containing `Maybe`s and returns a dictionary of all the non-empty values. */ export const catMaybesDictionary = < T > ( maybesDictionary ) : { [ index ] : T ; } => pickBy ( maybesDictionary as Record < string , Maybe < T > > , ( _key , value ) : value is T => isMaybeDefined ( value ) ) ; export const mapValueIfDefined = < V , V2 > ( fn ) => ( maybe ) => isMaybeDefined ( maybe ) ? fn ( maybe ) : undefined ;