blob: 250d595ebe6f9c7461d13cf5888f92d2c39e89a9 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
|
export const ifUndefinedString = (source: string | undefined | null, defaultValue: string): string => (source !== undefined && source !== null ? source : defaultValue);
export const ifUndefinedBoolean = (source: boolean | undefined | null, defaultValue: boolean): boolean => Boolean(source !== undefined && source !== null ? source : defaultValue);
export const ifUndefinedNumber = (source: number | undefined | null, defaultValue: number): number => Number(source !== undefined && source !== null ? source : 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))
|