import { isNotNullAndTrue } from '../boolean' import { defaultFn } from './default-function' import { FunctionReturningType } from '../types' export const ifThenElse: (ifFn: FunctionReturningType, thenFn: FunctionReturningType, elseFn?: FunctionReturningType) => (...args: any) => B | C = (ifFn, thenFn, elseFn = defaultFn) => (...args) => isNotNullAndTrue(ifFn)(...args) ? thenFn(...args) : elseFn(...args)