UNPKG

@monstermann/fn

Version:

A utility library for TypeScript.

25 lines (23 loc) 596 B
import { dfdlT } from "@monstermann/dfdl"; import { markAsMutable } from "@monstermann/remmi"; //#region src/array/concat.ts /** * `concat(array, source)` * * Concatenates `source` array to the end of `array`, returning a new array with the combined elements. * * ```ts * concat([1, 2], [3, 4]); // [1, 2, 3, 4] * ``` * * ```ts * pipe([1, 2], concat([3, 4])); // [1, 2, 3, 4] * ``` */ const concat = dfdlT((target, source) => { if (source.length === 0) return target; if (target.length === 0) return source; return markAsMutable(target.concat(source)); }, 2); //#endregion export { concat };