Skip to content

Instantly share code, notes, and snippets.

@imbudhiraja
Created April 19, 2019 04:27
Show Gist options
  • Save imbudhiraja/b3b995822a90d057f3af665ca8de9490 to your computer and use it in GitHub Desktop.
Save imbudhiraja/b3b995822a90d057f3af665ca8de9490 to your computer and use it in GitHub Desktop.
import _ from 'lodash';
const keysTo = (keys) => {
if (Array.isArray(keys)) {
return keys.map((key) => snakeCaseCreator(key));
} if (_.isPlainObject(keys)) {
return Object.keys(keys).reduce(
(result, key) => ({
...result,
[_.snakeCase(key)]: snakeCaseCreator(obj[key]),
}),
{}
);
}
return keys;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment