Skip to content

clone

ts
function Array.clone<T>(target: readonly T[]): T[]

Creates a shallow copy of array, unless marked as mutable with markAsMutable inside a mutation context (see @monstermann/remmi).

Example

ts
import { Array } from "@monstermann/array";

Array.clone([1, 2, 3, 4]); // [1, 2, 3, 4]
ts
import { Array } from "@monstermann/array";

pipe([1, 2, 3, 4], Array.clone()); // [1, 2, 3, 4]