UNPKG

rambdax

Version:

Extended version of Rambda - a lightweight, faster alternative to Ramda

14 lines (10 loc) 311 B
import { type } from './type' export function maybe( ifRule, whenIf, whenElse ){ const whenIfInput = ifRule && type(whenIf) === 'Function' ? whenIf() : whenIf const whenElseInput = !ifRule && type(whenElse) === 'Function' ? whenElse() : whenElse return ifRule ? whenIfInput : whenElseInput }