function getHumpLineName (s) {
return s.replace(/_(w)/g, function (all, letter) {
return letter.toUpperCase()
})
}
function getUnderLineName (s) {
return s.replace(/([A-Z])/g, '_$1').toLowerCase()
}
export function toHumpLineNameStyle (obj) {
if (obj instanceof Array) {
obj.forEach(function (v) {
toHumpLineNameStyle(v)
})
} else if (obj instanceof Object) {
Object.keys(obj).forEach(function (key) {
let newKey = getHumpLineName(key)
if (newKey !== key) {
obj[newKey] = obj[key]
delete obj[key]
}
toHumpLineNameStyle(obj[newKey])
})
}
}
export function toUnderLineNameStyle (obj) {
if (obj instanceof Array) {
obj.forEach(function (v) {
(v)
})
} else if (obj instanceof Object) {
Object.keys(obj).forEach(function (key) {
let newKey = getUnderLineName(key)
if (newKey !== key) {
obj[newKey] = obj[key]
delete obj[key]
}
toUnderLineNameStyle(obj[newKey])
})
}
}