import type { Arr } from '@toolbox-ts/types/defs/array'; /** * Defines how to clone arrays. * - 'shallow': Creates a shallow copy using the spread operator. * - 'structured': Uses `structuredClone` for deep cloning (requires Node.js 17+). * - Custom function: A user-defined function that takes the array and returns a cloned array. */ export type CloneStrategy = 'structured' | 'shallow' | { depth: number; handler: (v: T[number]) => T[number]; }; /** * Clones an array using the specified strategy. * - 'shallow': Creates a shallow copy using the spread operator. * - 'structured': Uses `structuredClone` for deep cloning (requires Node.js 17+). * - Custom function: A user-defined function that takes the array and returns a cloned array. * * @pure * * @example * ```ts * const original = [{ a: 1 }, { b: 2 }]; * const shallowClone = clone(original, 'shallow'); * const deepClone = clone(original, 'structured'); * const customClone = clone(original, (arr) => arr.map(item => ({ ...item }))); * ``` */ export declare const clone: (arr: T, strategy?: CloneStrategy) => T;