object-keys-mapping
v3.0.0
Published
mapping object keys
Downloads
38
Readme
object-keys-mapping
APIs
Operator
- .map()
reverseCamelcase()
toCamelcase()
trim()
Usage
import { Operator } from 'object-keys-mapping'
const operator = new Operator({
camelcase: true,
mapping: {
'.title': '.name',
'.info.nick': 'nickname',
'.items.title': 'name'
}
})
const obj = operator.map({
user_id: 123,
title: 'hi',
info: {
nick: 'cat'
},
items: [{
title: 'dog'
}]
})
// obj is:
{
userId: 123,
name: 'hi',
info: {
nickname: 'cat'
},
items: [{
name: 'dog'
}]
}
toCamelcase({
user_name: 'hi',
age: 8
})
reverseCamelcase({
userName: 'hi',
age: 8
})
License
MIT