switch-functional
Version:
Functional switch statement
29 lines (13 loc) • 266 B
JavaScript
export const applyReturnValues=(
input,
returnValues,
{
mapReturnValues
})=>
{
const returnValue=
mapReturnValues===undefined?
returnValues[0]:
mapReturnValues(...returnValues);
return typeof returnValue==="function"?returnValue(input):returnValue
};