Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | 70x 626x 626x 626x 3835x 3835x 108x 3727x 626x 70x 160x 160x 624x 624x 160x | export const snakeCase = (input: string): string => {
const result = [];
const splitString = input.split('');
for (let i = 0; i < splitString.length; i++) {
const char = splitString[i];
if (i !== 0 && char.toLocaleUpperCase() === char) {
result.push('_', char.toLocaleLowerCase());
} else {
result.push(char.toLocaleLowerCase());
}
}
return result.join('');
};
export const snakeCaseKeys = (obj: {
[index: string]: any;
}): { [index: string]: any } => {
const objResult: { [index: string]: any } = {};
Object.keys(obj).forEach((key) => {
const snakeCaseKey = snakeCase(key);
objResult[snakeCaseKey] = obj[key];
});
return objResult;
};
|