daily pastebin goal
31%
SHARE
TWEET

Untitled

a guest Feb 14th, 2018 53 Never
Upgrade to PRO!
ENDING IN00days00hours00mins00secs
  1. import {
  2.     camelCase,
  3.     mapKeys,
  4.     mapValues,
  5.     pick,
  6.     isPlainObject,
  7.     isArray
  8. } from 'lodash';
  9.  
  10. const toCamelCaseKey = obj => mapKeys(obj, (value, key) => camelCase(key));
  11.  
  12. // recursively traverse an object to convert all keys to camel case
  13. const toCamelCaseDeep = obj => {
  14.     if (isPlainObject(obj)) {
  15.         return mapValues(toCamelCaseKey(obj), toCamelCaseDeep);
  16.     } else if (isArray(obj)) {
  17.         return obj.map(toCamelCaseDeep);
  18.     } else {
  19.         return obj;
  20.     }
  21. };
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. OK, I Understand
 
Top