updeep-remeda/lib/in.js
Aaron Jensen 750200df76 Add u.if
2015-08-04 23:57:01 -07:00

12 lines
318 B
JavaScript

import curry from 'lodash/function/curry';
import update from './update';
function updateIn(path, value, obj) {
const parts = Array.isArray(path) ? path : path.split('.');
const updates = parts.reduceRight((acc, key) => ({ [key]: acc }), value);
return update(updates, obj);
}
export default curry(updateIn);