updeep-remeda/lib/updateIn.js

13 lines
328 B
JavaScript

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