Skip to content

Commit

Permalink
Merge pull request #2075 from voxel51/bookmark-l3d-issue
Browse files Browse the repository at this point in the history
Looker3D Settings Issue
  • Loading branch information
brimoor authored Sep 8, 2022
2 parents d8d635e + a724fb9 commit c53d7a8
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion app/packages/utilities/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,18 @@ interface O {

export const toCamelCase = (obj: O): O =>
_.transform(obj, (acc, value, key, target) => {
const camelKey = _.isArray(target) ? key : _.camelCase(key);
const camelKey = _.isArray(target) ? key : safeCamelCase(key);

acc[
`${typeof key === "string" && key.startsWith("_") ? "_" : ""}${camelKey}`
] = _.isObject(value) ? toCamelCase(value) : value;
});

function safeCamelCase(key) {
if (key.match(/[0-9][a-z]/)) return key;
return _.camelCase(key);
}

export const toSnakeCase = (obj: O): O =>
_.transform(obj, (acc, value, key, target) => {
const snakeKey = _.isArray(target) ? key : _.snakeCase(key);
Expand Down

0 comments on commit c53d7a8

Please sign in to comment.