@jswork/next-key-map
v1.0.11
Published
Recursion replace object key use map.
Downloads
101
Readme
next-key-map
Recursion replace object key use map.
installation
npm install -S @jswork/next-key-map
apis
| API | TYPE | DESCRIPTION | |--------|-------------------------|----------------------| | keyMap | { sourceKey: targetKey} | Map source to target |
usage
import '@jswork/next-key-map';
const data = {
key: '1',
name: 'Zhong Hua Men',
desc: 'lsjdflsjdflsdjflsjdf'
};
const rs = nx.keyMap( data,{
key:'id',
name:'value',
desc:'description'
});
// or use id:value replacer
const rs2 = nx.keyMap(data, 'key:id; name:value; desc:description');
// results:
const data = {
id: '1',
value: 'Zhong Hua Men',
description: 'lsjdflsjdflsdjflsjdf'
};
license
Code released under the MIT license.