department-of-veterans-affairs/vets-website

View on GitHub
src/platform/utilities/data/camelCaseObjectKeys.js

Summary

Maintainability
A
0 mins
Test Coverage
import _ from 'lodash';

export default function objectKeysToCamelCase(obj) {
  return _.reduce(
    obj,
    (result, value, key) => {
      const finalValue =
        _.isPlainObject(value) || _.isArray(value)
          ? objectKeysToCamelCase(value)
          : value;
      return { ...result, [_.camelCase(key)]: finalValue };
    },
    {},
  );
}