From b49b1010c271e40508e19e50c2a135bcb5279b37 Mon Sep 17 00:00:00 2001 From: github-actions Date: Wed, 19 Jul 2023 16:09:38 +0000 Subject: [PATCH] push build files [skip ci] --- lib/cjs/helpers/general.d.ts | 1 + lib/cjs/helpers/general.js | 21 ++++++++++++++++++++- lib/cjs/helpers/index.d.ts | 4 ++-- lib/cjs/helpers/index.js | 3 ++- lib/esm/helpers/general.d.ts | 1 + lib/esm/helpers/general.js | 18 ++++++++++++++++++ lib/esm/helpers/index.d.ts | 4 ++-- lib/esm/helpers/index.js | 8 ++++++-- 8 files changed, 52 insertions(+), 8 deletions(-) diff --git a/lib/cjs/helpers/general.d.ts b/lib/cjs/helpers/general.d.ts index 9c88b86d..4bb6653a 100644 --- a/lib/cjs/helpers/general.d.ts +++ b/lib/cjs/helpers/general.d.ts @@ -8,3 +8,4 @@ export interface Path { [subpath: string]: string | Path; } export declare function path>(_: string, subpaths?: Subpaths): Path & Subpaths; +export declare function snakeCaseToCamelCase(obj: Record): void; diff --git a/lib/cjs/helpers/general.js b/lib/cjs/helpers/general.js index 5cfbf666..a5a06ab6 100644 --- a/lib/cjs/helpers/general.js +++ b/lib/cjs/helpers/general.js @@ -11,7 +11,7 @@ var __assign = (this && this.__assign) || function () { return __assign.apply(this, arguments); }; Object.defineProperty(exports, "__esModule", { value: true }); -exports.path = exports.wrap = exports.openInNewTab = void 0; +exports.snakeCaseToCamelCase = exports.path = exports.wrap = exports.openInNewTab = void 0; function openInNewTab(url, target) { if (target === void 0) { target = '_blank'; } window.open(url, target); @@ -64,3 +64,22 @@ subpaths) { return path; } exports.path = path; +function snakeCaseToCamelCase(obj) { + Object.entries(obj).forEach(function (_a) { + var snakeKey = _a[0], value = _a[1]; + if (typeof value === 'object') + snakeCaseToCamelCase(value); + var keys = snakeKey.split('_').filter(function (key) { return key !== ''; }); + if (keys.length >= 1) { + var camelCaseKey = keys.reduce(function (previousValue, currentValue) { + return previousValue + + currentValue.charAt(0).toUpperCase() + + currentValue.slice(1); + }); + // eslint-disable-next-line @typescript-eslint/no-dynamic-delete + delete obj[snakeKey]; + obj[camelCaseKey] = value; + } + }); +} +exports.snakeCaseToCamelCase = snakeCaseToCamelCase; diff --git a/lib/cjs/helpers/index.d.ts b/lib/cjs/helpers/index.d.ts index 18cd5ed9..09cc1752 100644 --- a/lib/cjs/helpers/index.d.ts +++ b/lib/cjs/helpers/index.d.ts @@ -1,3 +1,3 @@ -import { openInNewTab, wrap, path, Path } from './general'; +import { openInNewTab, wrap, path, Path, snakeCaseToCamelCase } from './general'; import { insertDividerBetweenElements, getStyleOverrides, getClassNames, includesClassNames, matchClassNames } from './materialUI'; -export { openInNewTab, wrap, path, type Path, insertDividerBetweenElements, getStyleOverrides, getClassNames, includesClassNames, matchClassNames }; +export { openInNewTab, wrap, path, type Path, snakeCaseToCamelCase, insertDividerBetweenElements, getStyleOverrides, getClassNames, includesClassNames, matchClassNames }; diff --git a/lib/cjs/helpers/index.js b/lib/cjs/helpers/index.js index 78820be7..3299fd33 100644 --- a/lib/cjs/helpers/index.js +++ b/lib/cjs/helpers/index.js @@ -1,10 +1,11 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -exports.matchClassNames = exports.includesClassNames = exports.getClassNames = exports.getStyleOverrides = exports.insertDividerBetweenElements = exports.path = exports.wrap = exports.openInNewTab = void 0; +exports.matchClassNames = exports.includesClassNames = exports.getClassNames = exports.getStyleOverrides = exports.insertDividerBetweenElements = exports.snakeCaseToCamelCase = exports.path = exports.wrap = exports.openInNewTab = void 0; var general_1 = require("./general"); Object.defineProperty(exports, "openInNewTab", { enumerable: true, get: function () { return general_1.openInNewTab; } }); Object.defineProperty(exports, "wrap", { enumerable: true, get: function () { return general_1.wrap; } }); Object.defineProperty(exports, "path", { enumerable: true, get: function () { return general_1.path; } }); +Object.defineProperty(exports, "snakeCaseToCamelCase", { enumerable: true, get: function () { return general_1.snakeCaseToCamelCase; } }); var materialUI_1 = require("./materialUI"); Object.defineProperty(exports, "insertDividerBetweenElements", { enumerable: true, get: function () { return materialUI_1.insertDividerBetweenElements; } }); Object.defineProperty(exports, "getStyleOverrides", { enumerable: true, get: function () { return materialUI_1.getStyleOverrides; } }); diff --git a/lib/esm/helpers/general.d.ts b/lib/esm/helpers/general.d.ts index 9c88b86d..4bb6653a 100644 --- a/lib/esm/helpers/general.d.ts +++ b/lib/esm/helpers/general.d.ts @@ -8,3 +8,4 @@ export interface Path { [subpath: string]: string | Path; } export declare function path>(_: string, subpaths?: Subpaths): Path & Subpaths; +export declare function snakeCaseToCamelCase(obj: Record): void; diff --git a/lib/esm/helpers/general.js b/lib/esm/helpers/general.js index 25cda350..1222e53b 100644 --- a/lib/esm/helpers/general.js +++ b/lib/esm/helpers/general.js @@ -58,3 +58,21 @@ subpaths) { } return path; } +export function snakeCaseToCamelCase(obj) { + Object.entries(obj).forEach(function (_a) { + var snakeKey = _a[0], value = _a[1]; + if (typeof value === 'object') + snakeCaseToCamelCase(value); + var keys = snakeKey.split('_').filter(function (key) { return key !== ''; }); + if (keys.length >= 1) { + var camelCaseKey = keys.reduce(function (previousValue, currentValue) { + return previousValue + + currentValue.charAt(0).toUpperCase() + + currentValue.slice(1); + }); + // eslint-disable-next-line @typescript-eslint/no-dynamic-delete + delete obj[snakeKey]; + obj[camelCaseKey] = value; + } + }); +} diff --git a/lib/esm/helpers/index.d.ts b/lib/esm/helpers/index.d.ts index 18cd5ed9..09cc1752 100644 --- a/lib/esm/helpers/index.d.ts +++ b/lib/esm/helpers/index.d.ts @@ -1,3 +1,3 @@ -import { openInNewTab, wrap, path, Path } from './general'; +import { openInNewTab, wrap, path, Path, snakeCaseToCamelCase } from './general'; import { insertDividerBetweenElements, getStyleOverrides, getClassNames, includesClassNames, matchClassNames } from './materialUI'; -export { openInNewTab, wrap, path, type Path, insertDividerBetweenElements, getStyleOverrides, getClassNames, includesClassNames, matchClassNames }; +export { openInNewTab, wrap, path, type Path, snakeCaseToCamelCase, insertDividerBetweenElements, getStyleOverrides, getClassNames, includesClassNames, matchClassNames }; diff --git a/lib/esm/helpers/index.js b/lib/esm/helpers/index.js index 919418cd..d5ee4b8e 100644 --- a/lib/esm/helpers/index.js +++ b/lib/esm/helpers/index.js @@ -1,4 +1,8 @@ -import { openInNewTab, wrap, path } from './general'; +import { openInNewTab, wrap, path, snakeCaseToCamelCase } from './general'; import { insertDividerBetweenElements, getStyleOverrides, getClassNames, includesClassNames, matchClassNames } from './materialUI'; // global -export { openInNewTab, wrap, path, insertDividerBetweenElements, getStyleOverrides, getClassNames, includesClassNames, matchClassNames }; +export { +// general +openInNewTab, wrap, path, snakeCaseToCamelCase, +// materialUI +insertDividerBetweenElements, getStyleOverrides, getClassNames, includesClassNames, matchClassNames };