17 lines
320 B
JavaScript
17 lines
320 B
JavaScript
import curry from 'lodash/function/curry';
|
|
import update from './update';
|
|
|
|
function updateIf(predicate, updates, object) {
|
|
const test = typeof predicate === 'function' ?
|
|
predicate(object) :
|
|
predicate;
|
|
|
|
if (!test) {
|
|
return object;
|
|
}
|
|
|
|
return update(updates, object);
|
|
}
|
|
|
|
export default curry(updateIf);
|