{"version":3,"sources":["../../src/functions/unique/unique.ts"],"names":[],"mappings":";AAEO,SAAS,OACd,UACA,aAA4B,mBACvB;AACL,MAAI,eAAe,mBAAmB;AAEpC,WAAO,CAAC,GAAG,IAAI,IAAI,QAAQ,CAAC;AAAA,EAC9B;AAEA,QAAM,SAAc,CAAC;AAErB,aAAW,SAAS,YAAY,CAAC,GAAG;AAClC,QAAI,CAAC,OAAO,KAAK,CAAC,UAAU,WAAW,OAAO,KAAK,CAAC,GAAG;AACrD,aAAO,KAAK,KAAK;AAAA,IACnB;AAAA,EACF;AAEA,SAAO;AACT;AAOA,IAAM,oBAAyC,OAAO","sourcesContent":["import { Maybe } from '../../types';\n\nexport function unique<T>(\n  iterable: Maybe<Iterable<T>>,\n  comparator: Comparator<T> = defaultComparator\n): T[] {\n  if (comparator === defaultComparator) {\n    // we can get a performance boost for the default case, which is probably the most common.\n    return [...new Set(iterable)];\n  }\n\n  const result: T[] = [];\n\n  for (const value of iterable ?? []) {\n    if (!result.some((other) => comparator(value, other))) {\n      result.push(value);\n    }\n  }\n\n  return result;\n}\n\n/**\n * Checks if two values are equal.\n */\ntype Comparator<T> = (a: T, b: T) => boolean;\n\nconst defaultComparator: Comparator<unknown> = Object.is;\n"]}