{"version":3,"sources":["../../src/functions/partition/partition.ts"],"names":[],"mappings":";AA4BO,SAAS,UACd,OACA,WACsC;AACtC,MAAI,SAAS,MAAM;AACjB,WAAO,CAAC,CAAC,GAAG,CAAC,CAAC;AAAA,EAChB;AAEA,QAAM,SAAc,CAAC;AACrB,QAAM,YAAkC,CAAC;AAEzC,aAAW,QAAQ,OAAO;AACxB,QAAI,UAAU,IAAI,GAAG;AACnB,aAAO,KAAK,IAAS;AAAA,IACvB,OAAO;AACL,gBAAU,KAAK,IAAqB;AAAA,IACtC;AAAA,EACF;AAEA,SAAO,CAAC,QAAQ,SAAS;AAC3B","sourcesContent":["import { Maybe } from '../../types';\n\n/**\n * Partitions an array into two arrays based on a predicate function.\n * @param array The input array to partition.\n * @param predicate A function that takes an array item and returns a boolean indicating whether the item should be included in the \"equals\" array or the \"notEquals\" array.\n * @returns A tuple containing two arrays: the \"equals\" array and the \"notEquals\" array.\n */\nexport function partition<T, S extends T>(\n  array: Maybe<readonly T[]>,\n  predicate: (item: T) => item is S\n): readonly [equals: S[], notEquals: Array<Exclude<T, S>>];\n/**\n * Partitions an array into two arrays based on a predicate function.\n * @param array The input array to partition.\n * @param predicate A function that takes an array item and returns a boolean indicating whether the item should be included in the \"equals\" array or the \"notEquals\" array.\n * @returns A tuple containing two arrays: the \"equals\" array and the \"notEquals\" array.\n */\nexport function partition<T>(\n  array: Maybe<readonly T[]>,\n  predicate: (item: T) => boolean\n): readonly [equals: T[], notEquals: T[]];\n/**\n * Implementation of all overloads.\n * @param array The input array to partition.\n * @param predicate A function that takes an array item and returns a boolean indicating whether the item should be included in the \"equals\" array or the \"notEquals\" array.\n * @returns A tuple containing two arrays: the \"equals\" array and the \"notEquals\" array.\n */\nexport function partition<T, S extends T>(\n  array: Maybe<readonly T[]>,\n  predicate: ((item: T) => item is S) | ((item: T) => boolean)\n): readonly [S[], Array<Exclude<T, S>>] {\n  if (array == null) {\n    return [[], []];\n  }\n\n  const equals: S[] = [];\n  const notEquals: Array<Exclude<T, S>> = [];\n\n  for (const item of array) {\n    if (predicate(item)) {\n      equals.push(item as S);\n    } else {\n      notEquals.push(item as Exclude<T, S>);\n    }\n  }\n\n  return [equals, notEquals];\n}\n"]}