import isString from '../../is/isString'; interface IHasArrayUniqueValuesOptions { itemMapper?: (item: Item) => string | number | boolean; ignoreCase?: boolean; // default true } export default function hasArrayUniqueValues( arr: Item[], options: IHasArrayUniqueValuesOptions = {}, ): boolean { const { itemMapper = (item: Item): string | number | boolean => (item as unknown as string), ignoreCase = true, } = options; const enhancedItemMapper = ignoreCase ? (item: Item): string | number | boolean => { const temp = itemMapper(item); return isString(temp) ? temp.toLowerCase() : temp; } : itemMapper; return arr.length === new Set(arr.map(enhancedItemMapper)).size; }