import { isNullOrUndefined } from "util"; export function isNullOrEmpty(arrayValue: Array | Set): boolean { if (arrayValue instanceof Array) { return isNullOrUndefined(arrayValue) || arrayValue.length === 0; } else if (arrayValue instanceof Set) { return isNullOrUndefined(arrayValue) || arrayValue.size === 0; } else { return false; } } export function isNotNullAndNotEmpty(arrayValue: Array | Set): boolean { if (arrayValue instanceof Array) { return !isNullOrUndefined(arrayValue) && arrayValue.length > 0; } else if (arrayValue instanceof Set) { return !isNullOrUndefined(arrayValue) && arrayValue.size > 0; } else { return false; } } export function concat(list_1: T[], list_2: T[]): T[] { if (!isNullOrUndefined(list_1) && !isNullOrUndefined(list_2)) { return list_1.concat(list_2); } else if (!isNullOrUndefined(list_1)) { return list_1; } else if (!isNullOrUndefined(list_2)) { return list_2; } return undefined; } export function removeItem(list: T[], item: T): void { if (!isNullOrUndefined(list)) { let index: number = list.findIndex(element => element === item); if (index >= 0) { list.splice(index, 1); } } }