mirror of
https://github.com/iib0011/omni-tools.git
synced 2025-09-21 06:59:33 +02:00
feat: stringify json
This commit is contained in:
@@ -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, '"')
|
||||
|
Reference in New Issue
Block a user