blob: 36d70da256a805369801920d9d20ae00706f508a (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
// TODO: ifUndefinedString can be removed after ./src/webview/recipe.js is converted to typescript.
export const ifUndefinedString = (
source: string | undefined | null,
defaultValue: string,
): string => (source !== undefined && source !== null ? source : defaultValue);
export const ifUndefined = <T>(
source: undefined | null | T,
defaultValue: T,
): T => {
if (source !== undefined && source !== null) {
return source;
}
return defaultValue;
};
export const convertToJSON = (data: string | any | undefined | null) =>
data && typeof data === 'string' && data.length > 0 ? JSON.parse(data) : data;
export const cleanseJSObject = (data: any | undefined | null) =>
JSON.parse(JSON.stringify(data));
export const isEscKeyPress = (keyCode : Number) => keyCode === 27;
|