import { isArray , isEmpty , isNil } from 'lodash/fp' ; export const executeIfFunction = ( fn ) => ( typeof fn === 'function' ? fn ( ) : fn ) ; export const getOrNil = < T > ( fallback = undefined ) => < X > ( value ? ) => ( isNil ( value ) || ! value ? fallback : value ) ; export const getOrEmpty = < T > ( fallback = [ ] ) => < X > ( value ? ) => ( ! ( isArray ( value ) && ! isEmpty ( value ) ) ? fallback : value ) ; const switchCaseBase = ( cases ) => ( defaultCase ? ) => ( key ) => ( cases . hasOwnProperty ( key ) ? cases [ key ] : defaultCase ) ; export const switchCase = ( cases ) => ( defaultCase ? ) => ( key ) => executeIfFunction ( switchCaseBase ( cases ) ( defaultCase ) ( key ) ) ;