updeep-remeda/lib/ifElse.js
Aaron Jensen ddd5c84d49 Add u.ifElse
Fixes #12
2015-08-05 23:10:16 -07:00

15 lines
344 B
JavaScript

import update from './update';
import wrap from './wrap';
function updateIfElse(predicate, trueUpdates, falseUpdates, object) {
const test = typeof predicate === 'function' ?
predicate(object) :
predicate;
const updates = test ? trueUpdates : falseUpdates;
return update(updates, object);
}
export default wrap(updateIfElse);