2015-08-05 06:36:40 +00:00
|
|
|
import update from './update';
|
2015-08-05 11:29:30 +00:00
|
|
|
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);
|