Since: 06/04/2015 Author: Thales Pinheiro
A JS library to deep rename object keys based on a map.
- Deep structure renamer
- Blazing fast (~2ms and ~5,737 ops/sec)!
- Low footprint (~1KB)
npm install key-renamer --save
Given this sample object:
const data = {
a: 1,
b: 'John',
c: 34,
d: 500000,
e: {
f: 10
},
active: true
};
and this sample map object:
const map = {
a: 'id',
b: 'name',
c: 'age',
d: '{project: {value: {total: $value}}}',
e: 'git',
f: '{repository: {url: $value}}'
};
running:
const keyRenamer = require("key-renamer");
console.log(keyRenamer(data, map));
the output transformed object should be:
const updatedObject = {
id: 1,
name: 'John',
age: 34,
project: {
value: {
total: 500000
}
},
git: {
repository: {
url: 10
}
},
active: true
};
- Clone this repository
npm install
- To test
npm run test
- To benchmark
npm run benchmark