SHARE
TWEET

Untitled




Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
- import {
- camelCase,
- mapKeys,
- mapValues,
- pick,
- isPlainObject,
- isArray
- } from 'lodash';
- const toCamelCaseKey = obj => mapKeys(obj, (value, key) => camelCase(key));
- // recursively traverse an object to convert all keys to camel case
- const toCamelCaseDeep = obj => {
- if (isPlainObject(obj)) {
- return mapValues(toCamelCaseKey(obj), toCamelCaseDeep);
- } else if (isArray(obj)) {
- return obj.map(toCamelCaseDeep);
- } else {
- return obj;
- }
- };
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.