mirror of
https://github.com/zed-industries/zed.git
synced 2025-01-11 21:13:02 +00:00
6734a0e69d
Co-Authored-By: Nate Butler <1714999+iamnbutler@users.noreply.github.com>
21 lines
532 B
TypeScript
21 lines
532 B
TypeScript
import { snakeCase } from "case-anything";
|
|
|
|
export default function decamelizeTree(object: { [key: string]: any }) {
|
|
const snakeObject: { [key: string]: any } = {};
|
|
for (const key in object) {
|
|
snakeObject[snakeCase(key)] = decamelizeValue(object[key]);
|
|
}
|
|
return snakeObject;
|
|
}
|
|
|
|
function decamelizeValue(value: any): any {
|
|
if (typeof value === "object") {
|
|
if (Array.isArray(value)) {
|
|
return value.map(decamelizeValue);
|
|
} else {
|
|
return decamelizeTree(value);
|
|
}
|
|
} else {
|
|
return value;
|
|
}
|
|
}
|