updeep-remeda/lib/in.js
2015-08-05 00:31:10 -07:00

12 lines
324 B
JavaScript

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