updeep-remeda/lib/if.js

17 lines
320 B
JavaScript
Raw Normal View History

2015-08-05 06:36:40 +00:00
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);