For an slighly cleaner alternative:
import {cond, inRange, subTrue} from 'lodash/fp' const getColor = cond([ [inRange(0, 5), () => 'red'], [inRange(5, 10), () => 'blue')], [stubTrue, () => 'green'] ])
I did not assume imports to be present. I guess the methods could also be destructured from _ like
_
const {cond, inRange, ...} = _; ...
And using them without _. prefix.
_.
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
For an slighly cleaner alternative:
I did not assume imports to be present. I guess the methods could also be destructured from
_
likeAnd using them without
_.
prefix.