Skip to content

Shortcut method to quickly set/get many values

Notifications You must be signed in to change notification settings

MrHen/lodash-setall

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

lodash-setall [Build Status]

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.

About

Shortcut method to quickly set/get many values

Resources

Stars

Watchers

Forks

Packages