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

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

Added visualizations

  • Property mode set to 100644
File size: 847 bytes
Line 
1'use strict';
2
3Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
5const isArray = require('../compat/predicate/isArray.js');
6const isPlainObject = require('../predicate/isPlainObject.js');
7const camelCase = require('../string/camelCase.js');
8
9function toCamelCaseKeys(obj) {
10 if (isArray.isArray(obj)) {
11 return obj.map(item => toCamelCaseKeys(item));
12 }
13 if (isPlainObject.isPlainObject(obj)) {
14 const result = {};
15 const keys = Object.keys(obj);
16 for (let i = 0; i < keys.length; i++) {
17 const key = keys[i];
18 const camelKey = camelCase.camelCase(key);
19 const convertedValue = toCamelCaseKeys(obj[key]);
20 result[camelKey] = convertedValue;
21 }
22 return result;
23 }
24 return obj;
25}
26
27exports.toCamelCaseKeys = toCamelCaseKeys;
Note: See TracBrowser for help on using the repository browser.