xlat

1.0.1 • Public • Published

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

/xlat/

    Package Sidebar

    Install

    npm i xlat

    Weekly Downloads

    3

    Version

    1.0.1

    License

    MIT

    Last publish

    Collaborators

    • bharathrao
    • nirmalgupta