Map keys in an object to achieve sanity.
$ npm install ivolo/map
var map = require('map');
var obj = {
peoples: 1,
a {
person: {
$first_name: 'Ilya',
LASTname: 'Volodarsky'
}
}
};
var schema = {
'count': 'peoples',
'contact.firstName': 'person.$first_name',
'contact.lastName': 'person.lastname',
'contact.name': 'a.person.name'
};
map(obj, schema);
// { count: 1, contact: { firstName: 'Ilya', lastName: 'Volodarsky' }}
Return another object with the obj
keys mapped according to the schema
.
WWWWWW||WWWWWW
W W W||W W W
||
( OO )__________
/ | \
/o o| MIT \
\___/||_||__||_|| *
|| || || ||
_||_|| _||_||
(__|__|(__|__|