1.0.1 • Published 8 years ago

xlat v1.0.1

Weekly downloads
3
License
MIT
Repository
github
Last release
8 years ago

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))