export default class ArrayUtil {
  public static isEmpty(array?: unknown[] | null): boolean {
    return !Array.isArray(array) || array.length === 0;
  }

  public static removeDuplicates<T>(array: T[], key: keyof T): T[] {
    const seen = new Set();
    return array.filter((item) => {
      const value = item[key];
      if (seen.has(value)) {
        return false;
      }
      seen.add(value);
      return true;
    });
  }

  public static uniqueStrings(array: string[]): string[] {
    return [...new Set(array.map((value) => value.toLowerCase()))];
  }
}
