lodash-setall
v2.0.0
Published
Lodash helper to call set/get repeatedly
Downloads
4
Readme
lodash-setall []
Uses lodash get/set pathing to map values from one object into another:
var _setAll = require('lodash-setall');
var origin = {
'b': 'something',
'c': { d: [0,1,2,3,4]},
'd': { 'foo': 'bar' }
};
var map = {
'a':'b',
'b':'c.d.2',
'c.a':'d'
};
var result = _setAll(origin, map, {});
// result = {
// 'a': 'something',
// 'b': 2,
// 'c': { 'a': { 'foo': 'bar'} }
//
For details on how the pathing works, see the documentation for _.get and _.set.