{"version":3,"file":"splice.js","names":[],"sources":["../src/splice.ts"],"sourcesContent":["import { purry } from \"./purry\";\n\n/**\n * Removes elements from an array and, inserts new elements in their place.\n *\n * @param items - The array to splice.\n * @param start - The index from which to start removing elements.\n * @param deleteCount - The number of elements to remove.\n * @param replacement - The elements to insert into the array in place of the deleted elements.\n * @signature\n *    splice(items, start, deleteCount, replacement)\n * @example\n *    splice([1,2,3,4,5,6,7,8], 2, 3, []); //=> [1,2,6,7,8]\n *    splice([1,2,3,4,5,6,7,8], 2, 3, [9, 10]); //=> [1,2,9,10,6,7,8]\n * @dataFirst\n * @category Array\n */\nexport function splice<T>(\n  items: readonly T[],\n  start: number,\n  deleteCount: number,\n  replacement: readonly T[],\n): T[];\n\n/**\n * Removes elements from an array and, inserts new elements in their place.\n *\n * @param start - The index from which to start removing elements.\n * @param deleteCount - The number of elements to remove.\n * @param replacement - The elements to insert into the array in place of the deleted elements.\n * @signature\n *    splice(start, deleteCount, replacement)(items)\n * @example\n *    pipe([1,2,3,4,5,6,7,8], splice(2, 3, [])) // => [1,2,6,7,8]\n *    pipe([1,2,3,4,5,6,7,8], splice(2, 3, [9, 10])) // => [1,2,9,10,6,7,8]\n * @dataLast\n * @category Array\n */\nexport function splice<T>(\n  start: number,\n  deleteCount: number,\n  replacement: readonly T[],\n): (items: readonly T[]) => T[];\n\nexport function splice(...args: readonly unknown[]): unknown {\n  return purry(spliceImplementation, args);\n}\n\nfunction spliceImplementation<T>(\n  items: readonly T[],\n  start: number,\n  deleteCount: number,\n  replacement: readonly T[],\n): T[] {\n  // TODO [>2]: When node 18 reaches end-of-life bump target lib to ES2023+ and use `Array.prototype.toSpliced` here.\n  const result = [...items];\n  result.splice(start, deleteCount, ...replacement);\n  return result;\n}\n"],"mappings":"mCA4CA,SAAgB,EAAO,GAAG,EAAmC,CAC3D,OAAO,EAAM,EAAsB,EAAK,CAG1C,SAAS,EACP,EACA,EACA,EACA,EACK,CAEL,IAAM,EAAS,CAAC,GAAG,EAAM,CAEzB,OADA,EAAO,OAAO,EAAO,EAAa,GAAG,EAAY,CAC1C"}