Skip to content

leverj/xlat

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

XLAT

Translate objects from one set of keys to another

var canonical = {
  'transaction': ['tx', 'trans'],
  'address': ['addrText', 'addr']
}

var a = {
  "transaction": { "id": "2"},
  "addr": "12345",
  "transmit": true
}

var b = {
  "tx": { "id": "9"},
  "addrText": "95645"
}

var xlat = require('xlat')(canonical)

console.log(xlat.translate(a))

console.log(xlat.translate(a, [a, b]))

// lets update dictionary
var addendum = { 'send': ['transmit'] }
xlat.index(addendum)

console.log(xlat.translate(a))

About

Translate object from one set of keys to another

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published