{"version":3,"file":"sort.utils-BLq3ZICP.cjs","names":["a: WithCreatedAt","b: WithCreatedAt","a: WithUpdatedAt","b: WithUpdatedAt","arr: T[]","dateKey: GetKeysWithSpecificTypeValue<T, Date>","order: \"ASC\" | \"DESC\""],"sources":["../src/shared/sort.utils.ts"],"sourcesContent":["import type { GetKeysWithSpecificTypeValue } from \"./type.utils.ts\";\n\ntype WithCreatedAt = { createdAt: Date };\n\nexport const sortByCreatedAt = (a: WithCreatedAt, b: WithCreatedAt): number =>\n  a.createdAt.getTime() - b.createdAt.getTime();\nexport const sortByCreatedAtDesc = (\n  a: WithCreatedAt,\n  b: WithCreatedAt,\n): number => b.createdAt.getTime() - a.createdAt.getTime();\n\ntype WithUpdatedAt = { updatedAt: Date };\nexport const sortByUpdatedAt = (a: WithUpdatedAt, b: WithUpdatedAt): number =>\n  a.updatedAt.getTime() - b.updatedAt.getTime();\nexport const sortByUpdatedAtDesc = (\n  a: WithUpdatedAt,\n  b: WithUpdatedAt,\n): number => b.updatedAt.getTime() - a.updatedAt.getTime();\n\n// biome-ignore lint/suspicious/noExplicitAny: <explanation>\nexport const sortByDatesAsc = <T extends Record<string, any>>(\n  arr: T[],\n  dateKey: GetKeysWithSpecificTypeValue<T, Date>,\n): T[] => arr.sort((a, b) => a[dateKey].getTime() - b[dateKey].getTime());\n\n// biome-ignore lint/suspicious/noExplicitAny: <explanation>\nexport const sortByDatesDesc = <T extends Record<string, any>>(\n  arr: T[],\n  dateKey: GetKeysWithSpecificTypeValue<T, Date>,\n): T[] => arr.sort((a, b) => b[dateKey].getTime() - a[dateKey].getTime());\n\n// biome-ignore lint/suspicious/noExplicitAny: <explanation>\nexport const sortByDates = <T extends Record<string, any>>(\n  arr: T[],\n  dateKey: GetKeysWithSpecificTypeValue<T, Date>,\n  order: \"ASC\" | \"DESC\",\n): T[] =>\n  order === \"ASC\"\n    ? sortByDatesAsc(arr, dateKey)\n    : sortByDatesDesc(arr, dateKey);\n"],"mappings":";;;AAIA,MAAa,kBAAkB,CAACA,GAAkBC,MAChD,EAAE,UAAU,SAAS,GAAG,EAAE,UAAU,SAAS;AAC/C,MAAa,sBAAsB,CACjCD,GACAC,MACW,EAAE,UAAU,SAAS,GAAG,EAAE,UAAU,SAAS;AAG1D,MAAa,kBAAkB,CAACC,GAAkBC,MAChD,EAAE,UAAU,SAAS,GAAG,EAAE,UAAU,SAAS;AAC/C,MAAa,sBAAsB,CACjCD,GACAC,MACW,EAAE,UAAU,SAAS,GAAG,EAAE,UAAU,SAAS;AAG1D,MAAa,iBAAiB,CAC5BC,KACAC,YACQ,IAAI,KAAK,CAAC,GAAG,MAAM,EAAE,SAAS,SAAS,GAAG,EAAE,SAAS,SAAS,CAAC;AAGzE,MAAa,kBAAkB,CAC7BD,KACAC,YACQ,IAAI,KAAK,CAAC,GAAG,MAAM,EAAE,SAAS,SAAS,GAAG,EAAE,SAAS,SAAS,CAAC;AAGzE,MAAa,cAAc,CACzBD,KACAC,SACAC,UAEA,UAAU,QACN,eAAe,KAAK,QAAQ,GAC5B,gBAAgB,KAAK,QAAQ"}