diff options
Diffstat (limited to 'src/jsUtils.ts')
-rw-r--r-- | src/jsUtils.ts | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/jsUtils.ts b/src/jsUtils.ts index f6a1df2fe..0095028ef 100644 --- a/src/jsUtils.ts +++ b/src/jsUtils.ts | |||
@@ -3,15 +3,15 @@ export const ifUndefined = <T>( | |||
3 | defaultValue: T, | 3 | defaultValue: T, |
4 | ): T => source ?? defaultValue; | 4 | ): T => source ?? defaultValue; |
5 | 5 | ||
6 | export const convertToJSON = (data: string | any | undefined | null) => | 6 | export const convertToJSON = (data?: string | any | null) => |
7 | data && typeof data === 'string' && data.length > 0 ? JSON.parse(data) : data; | 7 | data && typeof data === 'string' && data.length > 0 ? JSON.parse(data) : data; |
8 | 8 | ||
9 | export const cleanseJSObject = (data: any | undefined | null) => | 9 | export const cleanseJSObject = (data?: any | null) => |
10 | JSON.parse(JSON.stringify(data)); | 10 | JSON.parse(JSON.stringify(data)); |
11 | 11 | ||
12 | export const isEscKeyPress = (keyCode: number) => keyCode === 27; | 12 | export const isEscKeyPress = (keyCode: number) => keyCode === 27; |
13 | 13 | ||
14 | export const safeParseInt = (text: string | number | undefined | null) => { | 14 | export const safeParseInt = (text?: string | number | null) => { |
15 | if (text === undefined || text === null) { | 15 | if (text === undefined || text === null) { |
16 | return 0; | 16 | return 0; |
17 | } | 17 | } |