MCPcopy Create free account
hub / github.com/ColmapView/Colmapview.github.io / camelToSnake

Function camelToSnake

src/config/configuration/converter.ts:15–37  ·  view source on GitHub ↗
(obj: unknown)

Source from the content-addressed store, hash-verified

13}
14
15export function camelToSnake(obj: unknown): JsonValue {
16 if (obj === null || obj === undefined) {
17 return null;
18 }
19
20 if (Array.isArray(obj)) {
21 return obj.map(camelToSnake);
22 }
23
24 if (isRecord(obj)) {
25 const result: { [key: string]: JsonValue } = {};
26 for (const [key, value] of Object.entries(obj)) {
27 result[toSnakeCase(key)] = camelToSnake(value);
28 }
29 return result;
30 }
31
32 if (typeof obj === 'string' || typeof obj === 'number' || typeof obj === 'boolean') {
33 return obj;
34 }
35
36 return null;
37}
38
39export function snakeToCamel(obj: unknown): unknown {
40 if (obj === null || obj === undefined) {

Callers 2

serializeConfigToYamlFunction · 0.90
serializer.test.tsFile · 0.90

Calls 3

entriesMethod · 0.80
isRecordFunction · 0.70
toSnakeCaseFunction · 0.70

Tested by

no test coverage detected