diff options
Diffstat (limited to 'src/jsUtils.ts')
-rw-r--r-- | src/jsUtils.ts | 23 |
1 files changed, 9 insertions, 14 deletions
diff --git a/src/jsUtils.ts b/src/jsUtils.ts index d7ea4eb40..250d595eb 100644 --- a/src/jsUtils.ts +++ b/src/jsUtils.ts | |||
@@ -1,14 +1,9 @@ | |||
1 | export const ifUndefinedString = ( | 1 | export const ifUndefinedString = (source: string | undefined | null, defaultValue: string): string => (source !== undefined && source !== null ? source : defaultValue); |
2 | source: string | undefined | null, | 2 | |
3 | defaultValue: string, | 3 | export const ifUndefinedBoolean = (source: boolean | undefined | null, defaultValue: boolean): boolean => Boolean(source !== undefined && source !== null ? source : defaultValue); |
4 | ): string => (source !== undefined && source !== null ? source : defaultValue); | 4 | |
5 | export const ifUndefinedBoolean = ( | 5 | export const ifUndefinedNumber = (source: number | undefined | null, defaultValue: number): number => Number(source !== undefined && source !== null ? source : defaultValue); |
6 | source: boolean | undefined | null, | 6 | |
7 | defaultValue: boolean, | 7 | export const convertToJSON = (data: string | any | undefined | null) => data && typeof data === 'string' && data.length > 0 ? JSON.parse(data) : data |
8 | ): boolean => | 8 | |
9 | Boolean(source !== undefined && source !== null ? source : defaultValue); | 9 | export const cleanseJSObject = (data: any | undefined | null) => JSON.parse(JSON.stringify(data)) |
10 | export const ifUndefinedNumber = ( | ||
11 | source: number | undefined | null, | ||
12 | defaultValue: number, | ||
13 | ): number => | ||
14 | Number(source !== undefined && source !== null ? source : defaultValue); | ||