UNPKG

remeda

Version:

A utility library for JavaScript and Typescript.

1 lines 2 kB
{"version":3,"file":"concat.cjs","names":["purry"],"sources":["../src/concat.ts"],"sourcesContent":["import type { IterableContainer } from \"./internal/types/IterableContainer\";\nimport { purry } from \"./purry\";\n\n/**\n * Merge two or more arrays. This method does not change the existing arrays,\n * but instead returns a new array, even if the other array is empty.\n *\n * @param data - The first items, these would be at the beginning of the new\n * array.\n * @param other - The remaining items, these would be at the end of the new\n * array.\n * @returns A new array with the items of the first array followed by the items\n * of the second array.\n * @signature\n * R.concat(data, other);\n * @example\n * R.concat([1, 2, 3], ['a']) // [1, 2, 3, 'a']\n * @dataFirst\n * @category Array\n */\nexport function concat<\n T1 extends IterableContainer,\n T2 extends IterableContainer,\n>(data: T1, other: T2): [...T1, ...T2];\n\n/**\n * Merge two or more arrays. This method does not change the existing arrays,\n * but instead returns a new array, even if the other array is empty.\n *\n * @param other - The remaining items, these would be at the end of the new\n * array.\n * @returns A new array with the items of the first array followed by the items\n * of the second array.\n * @signature\n * R.concat(arr2)(arr1);\n * @example\n * R.concat(['a'])([1, 2, 3]) // [1, 2, 3, 'a']\n * @dataLast\n * @category Array\n */\nexport function concat<T2 extends IterableContainer>(\n other: T2,\n): <T1 extends IterableContainer>(data: T1) => [...T1, ...T2];\n\nexport function concat(...args: readonly unknown[]): unknown {\n return purry(concatImplementation, args);\n}\n\nconst concatImplementation = <\n T1 extends IterableContainer,\n T2 extends IterableContainer,\n>(\n arr1: T1,\n arr2: T2,\n): [...T1, ...T2] => [...arr1, ...arr2];\n"],"mappings":"wCA4CA,SAAgB,EAAO,GAAG,EAAmC,CAC3D,OAAOA,EAAAA,EAAM,EAAsB,EAAK,CAG1C,MAAM,GAIJ,EACA,IACmB,CAAC,GAAG,EAAM,GAAG,EAAK"}