1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
|
const camelToSnake = (arg) => { return arg.replace(/([A-Z])/g, '_$1').toLowerCase() }, const objCamelToSnake = (obj) => { let newObj = {} let keys = Object.keys(obj) keys.forEach(keyItem => { newObj[this.camelToSnake(keyItem)] = obj[keyItem] }) return newObj }
|