Skip to content

Instantly share code, notes, and snippets.

@simongong
simongong / camelSnake.js
Created May 10, 2016 06:40
JavaScript: convert format of object keys between camel-case and snake-case
/**
* @param {Object|String} data string or keys of object are named in form of snake
* @param {number} depth to which level of keys should it process
* @return {Object|String} string or keys of object are named in form of camel case
*/
exports.snakeToCamel = function(data, depth) {
if (Util.isObject(data)) {
if (typeof depth === 'undefined') {
depth = 1;
}