source: node_modules/es-toolkit/dist/object/toCamelCaseKeys.mjs

Last change on this file was a762898, checked in by istevanoska <ilinastevanoska@…>, 5 months ago

Added visualizations

  • Property mode set to 100644
File size: 711 bytes
Line 
1import { isArray } from '../compat/predicate/isArray.mjs';
2import { isPlainObject } from '../predicate/isPlainObject.mjs';
3import { camelCase } from '../string/camelCase.mjs';
4
5function toCamelCaseKeys(obj) {
6 if (isArray(obj)) {
7 return obj.map(item => toCamelCaseKeys(item));
8 }
9 if (isPlainObject(obj)) {
10 const result = {};
11 const keys = Object.keys(obj);
12 for (let i = 0; i < keys.length; i++) {
13 const key = keys[i];
14 const camelKey = camelCase(key);
15 const convertedValue = toCamelCaseKeys(obj[key]);
16 result[camelKey] = convertedValue;
17 }
18 return result;
19 }
20 return obj;
21}
22
23export { toCamelCaseKeys };
Note: See TracBrowser for help on using the repository browser.