diff options
Diffstat (limited to 'src/jsUtils.ts')
-rw-r--r-- | src/jsUtils.ts | 14 |
1 files changed, 1 insertions, 13 deletions
diff --git a/src/jsUtils.ts b/src/jsUtils.ts index ba7542eab..b93d6db5b 100644 --- a/src/jsUtils.ts +++ b/src/jsUtils.ts | |||
@@ -1,19 +1,7 @@ | |||
1 | // TODO: ifUndefinedString can be removed after ./src/webview/recipe.js is converted to typescript. | ||
2 | export const ifUndefinedString = ( | ||
3 | source: string | undefined | null, | ||
4 | defaultValue: string, | ||
5 | ): string => (source !== undefined && source !== null ? source : defaultValue); | ||
6 | |||
7 | export const ifUndefined = <T>( | 1 | export const ifUndefined = <T>( |
8 | source: undefined | null | T, | 2 | source: undefined | null | T, |
9 | defaultValue: T, | 3 | defaultValue: T, |
10 | ): T => { | 4 | ): T => (source !== undefined && source !== null ? source : defaultValue); |
11 | if (source !== undefined && source !== null) { | ||
12 | return source; | ||
13 | } | ||
14 | |||
15 | return defaultValue; | ||
16 | }; | ||
17 | 5 | ||
18 | export const convertToJSON = (data: string | any | undefined | null) => | 6 | export const convertToJSON = (data: string | any | undefined | null) => |
19 | data && typeof data === 'string' && data.length > 0 ? JSON.parse(data) : data; | 7 | data && typeof data === 'string' && data.length > 0 ? JSON.parse(data) : data; |