Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions __tests__/concat.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { concat } from "@extremejs/utils";

it("should create a new array concatenating the input array with any additional arrays and/or values.", () => {
expect(concat<number[] | number>([1, 2], 3, [4], [[5]])).toEqual([1, 2, 3, 4, [5]]);
});
12 changes: 12 additions & 0 deletions src/concat.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/**
* It will create a new array concatenating the input `array` with any additional arrays and/or values.
* @since 1.0.0
* @param array
* @param items
* @example
* concat([1, 2], 3, [4], [[5]]);
* // => [1, 2, 3, 4, [5]]
*/
export default function concat<Value>(array: Value[], ...items: Array<ConcatArray<Value> | Value>): Value[] {
return array.concat(...items);
}
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ export { default as camelCase } from "./camel-case.js";
export { default as capitalize } from "./capitalize.js";
export { default as chunk } from "./chunk.js";
export { default as compact, type CompactT } from "./compact.js";
export { default as concat } from "./concat.js";
export { default as endsWith } from "./ends-with.js";
export { default as first, type FirstT } from "./first.js";
export { default as get, type RecordT, type CalculatedPropertyT, type CalculatedPathT, type ValueAtT } from "./get.js";
Expand Down