updeep-remeda/lib/ifElse.js

15 lines
344 B
JavaScript
Raw Normal View History

2015-08-05 06:36:40 +00:00
import update from './update';
import wrap from './wrap';
2015-08-05 06:36:40 +00:00
2015-08-06 06:10:16 +00:00
function updateIfElse(predicate, trueUpdates, falseUpdates, object) {
2015-08-05 06:36:40 +00:00
const test = typeof predicate === 'function' ?
predicate(object) :
predicate;
2015-08-06 06:10:16 +00:00
const updates = test ? trueUpdates : falseUpdates;
2015-08-05 06:36:40 +00:00
return update(updates, object);
}
2015-08-06 06:10:16 +00:00
export default wrap(updateIfElse);