{"version":3,"file":"remove.cjs","names":[],"sources":["../../src/array/remove.ts"],"sourcesContent":["/** Options for {@link remove}. */\nexport interface RemoveOptions {\n  /** The number of items to remove from the selected index. */\n  count?: number;\n}\n\n/**\n * Removes items at the given index or all elements matching the predicate.\n *\n * @param {T[]} arr The source array.\n * @param {number|Function} indexOrFn The index or predicate function.\n * @param {RemoveOptions} [options] Removal options; ignored when using a predicate.\n * @returns {T[]} A new array with the removed items.\n *\n * @example\n * remove([1, 2, 3], 1, { count: 2 }); //=> [1]\n * remove([1, 2, 3, 4, 5], (x) => x % 2 === 0); //=> [1, 3, 5]\n */\nexport default function remove<T>(\n  arr: T[] = [],\n  indexOrFn?: number | ((item: T, index: number, array: T[]) => boolean),\n  { count = 1 }: RemoveOptions = {},\n): T[] {\n  if (typeof indexOrFn === 'function') {\n    return arr.filter(\n      (item, index, array) =>\n        !(indexOrFn as (item: T, index: number, array: T[]) => boolean)(\n          item,\n          index,\n          array,\n        ),\n    );\n  }\n\n  const idx = indexOrFn ?? arr.length - 1;\n  const a = [...arr];\n  a.splice(idx, count);\n  return a;\n}\n"],"mappings":"+FAkBA,SAAwB,EACtB,EAAW,CAAC,EACZ,EACA,CAAE,QAAQ,GAAqB,CAAC,EAC3B,CACL,GAAI,OAAO,GAAc,WACvB,OAAO,EAAI,QACR,EAAM,EAAO,IACZ,CAAE,EACA,EACA,EACA,CACF,CACJ,EAGF,IAAM,EAAM,GAAa,EAAI,OAAS,EAChC,EAAI,CAAC,GAAG,CAAG,EAEjB,OADA,EAAE,OAAO,EAAK,CAAK,EACZ,CACT"}