{"version":3,"file":"partition.mjs","names":[],"sources":["../../src/collection/partition.ts"],"sourcesContent":["/**\n * Creates an array of elements split into two groups, the first of which contains elements predicate returns truthy for, the second of which contains elements predicate returns falsy for\n * @param collection - The collection to iterate over\n * @param predicate - The function invoked per iteration\n * @returns Returns the array of grouped elements\n * @example\n * const users = [\n *   { name: 'John', active: true },\n *   { name: 'Jane', active: false },\n *   { name: 'Bob', active: true }\n * ];\n * partition(users, 'active');\n * // => [[{name: 'John', active: true}, {name: 'Bob', active: true}], [{name: 'Jane', active: false}]]\n */\nexport function partition<T>(collection: T[], predicate: ((item: T, index: number) => boolean) | string): [T[], T[]] {\n  const trueGroup: T[] = [];\n  const falseGroup: T[] = [];\n\n  collection.forEach((item, index) => {\n    let result: boolean;\n\n    if (typeof predicate === 'function') {\n      result = predicate(item, index);\n    } else if (typeof predicate === 'string') {\n      // Handle property access like 'active'\n      result = !!(item as Record<string, unknown>)[predicate];\n    } else {\n      result = !!item;\n    }\n\n    if (result) {\n      trueGroup.push(item);\n    } else {\n      falseGroup.push(item);\n    }\n  });\n\n  return [trueGroup, falseGroup];\n}\n"],"mappings":";;;;;;;;;;;;;;;AAcA,SAAgB,UAAa,YAAiB,WAAuE;CACnH,MAAM,YAAiB,CAAC;CACxB,MAAM,aAAkB,CAAC;CAEzB,WAAW,SAAS,MAAM,UAAU;EAClC,IAAI;EAEJ,IAAI,OAAO,cAAc,YACvB,SAAS,UAAU,MAAM,KAAK;OACzB,IAAI,OAAO,cAAc,UAE9B,SAAS,CAAC,CAAE,KAAiC;OAE7C,SAAS,CAAC,CAAC;EAGb,IAAI,QACF,UAAU,KAAK,IAAI;OAEnB,WAAW,KAAK,IAAI;CAExB,CAAC;CAED,OAAO,CAAC,WAAW,UAAU;AAC/B"}