PageSourceSearch

https://smrtbld.ai/js/utils/case-transform.js

js smrtbld.ai collected 2026-10-05 15:08:36 UTC 1,383 bytes, 37 lines download raw bytes

1/**
2 * Recursive object key case transformation.
3 *
4 * Standalone module with zero imports — safe to use from auth.js,
5 * ApiClient, or any other file without circular dependency risk.
6 */
7
8/**
9 * Recursively convert object keys from PascalCase to camelCase.
10 * @param {*} obj - value to transform (objects/arrays are walked recursively)
11 * @returns {*} transformed value
12 */
13export function toCamelCase(obj) {
14    if (obj === null || typeof obj !== 'object') return obj;
15    if (Array.isArray(obj)) return obj.map(v => toCamelCase(v));
16    return Object.keys(obj).reduce((result, key) => {
17        const camelKey = key.charAt(0).toLowerCase() + key.slice(1);
18        result[camelKey] = toCamelCase(obj[key]);
19        return result;
20    }, {});
21}
22
23/**
24 * Recursively convert object keys from camelCase to PascalCase.
25 * Preserves File and Blob instances (used in FormData uploads).
26 * @param {*} obj - value to transform
27 * @returns {*} transformed value
28 */
29export function toPascalCase(obj) {
30    if (obj === null || typeof obj !== 'object' || obj instanceof File || obj instanceof Blob) return obj;
31    if (Array.isArray(obj)) return obj.map(v => toPascalCase(v));
32    return Object.keys(obj).reduce((result, key) => {
33        const pascalKey = key.charAt(0).toUpperCase() + key.slice(1);
34        result[pascalKey] = toPascalCase(obj[key]);
35        return result;
36    }, {});
37}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.