/2way

Primary LanguageJavaScript

2way

Build Status

Javascript 2 way mapping library

var mapping = [
  {server: ['name', 'given'], client: ['firstName']},
  {server: ['name', 'family'], client: ['lastName']},
  {server: ['address', {use: 'home'}, 'line'], client: ['address_line']}
];

// transform(object, [fromKey, toKey])
var result = mapper.transform(
 {address_line: 'line', firstName: 'ivan', lastName: 'ivanov'},
 ['client', 'server']
);

var result =  {
  name: {given: 'ivan', family: 'ivanov'},
  address: [{use: 'home', line: 'line'}]
}