feat: stringify json

This commit is contained in:
Ibrahima G. Coulibaly
2025-03-08 07:11:57 +00:00
parent 90d3c0801e
commit f678c76200
9 changed files with 243 additions and 25 deletions

View File

@@ -1,3 +1,5 @@
import { UpdateField } from '@components/options/ToolOptions';
export function capitalizeFirstLetter(string: string | undefined) {
if (!string) return '';
return string.charAt(0).toUpperCase() + string.slice(1);
@@ -7,6 +9,20 @@ export function isNumber(number: any) {
return !isNaN(parseFloat(number)) && isFinite(number);
}
export const updateNumberField = <T>(
val: string,
key: keyof T,
updateField: UpdateField<T>
) => {
if (val === '') {
// @ts-ignore
updateField(key, '');
} else if (isNumber(val)) {
// @ts-ignore
updateField(key, Number(val));
}
};
export const replaceSpecialCharacters = (str: string) => {
return str
.replace(/\\"/g, '"')