export interface CloneOptions { maxDepth?: number; preservePlainObjectStructure?: boolean; strategy?: CloneStrategy; structuredSerializeOptions?: StructuredSerializeOptions; } export type CloneStrategy = 'deep' | 'shallow' | 'structured'; interface CloneContext { currentDepth: number; maxDepth: number; preservePlainObjectStructure?: boolean; seen: WeakMap; } /** * Creates a shallow clone of an object while preserving its prototype and property descriptors. * * @example * ```ts * const obj = Object.create(null, { a: { value: 1, writable: false } }); * const cloned = cloneObjectStructure(obj); * Object.getPrototypeOf(cloned) === null; // true * Object.getOwnPropertyDescriptor(cloned, 'a')?.writable; // false * ``` */ export declare const cloneObjectStructure: (value: T) => T; export declare const copy: { readonly date: (value: Date) => Date; readonly regex: (value: RegExp) => RegExp; readonly arrayBuffer: (value: ArrayBuffer) => ArrayBuffer; readonly dataView: (value: ArrayBufferView) => DataView; readonly typedArray: (value: NodeJS.TypedArray) => NodeJS.TypedArray; readonly set: (value: Set) => Set; readonly map: (value: Map) => Map; readonly url: (value: URL) => URL; readonly array: (value: unknown[]) => unknown[]; readonly error: (value: Error) => Error; readonly plainObject: (value: Record, { preservePlainObjectStructure }: CloneContext) => Record; }; /** * Deeply clones a value with circular reference handling. * * Supported types: primitives, arrays, objects, Map, Set, Date, RegExp, * ArrayBuffer, TypedArrays, DataView, URL, Error. * * * @example * ```ts * const obj = { a: { b: { c: 1 } } }; * const cloned = cloneDeep(obj); * cloned.a.b !== obj.a.b; // true * * // With depth limit * const shallow = cloneDeep(obj, { depth: 1 }); * shallow.a.b === obj.a.b; // true (not cloned beyond depth 1) * ``` */ export declare const cloneDeep: (value: T, { maxDepth }?: { maxDepth?: number; }) => T; /** * Shallowly clones a value (top-level only). * * - Arrays: `[...arr]` * - Plain objects: Preserves prototype and property descriptors * - Built-in types: Date, RegExp, Map, Set, ArrayBuffer * * @throws TypeError If value cannot be shallow cloned * * @example * ```ts * const arr = [{ a: 1 }]; * const cloned = cloneShallow(arr); * cloned !== arr; // true * cloned[0] === arr[0]; // true (same reference) * ``` */ export declare const cloneShallow: (value: T, { preservePlainObjectStructure }?: { preservePlainObjectStructure?: boolean; }) => T; /** * Clones a value using the specified strategy. * * Strategies: * - `deep` (default): Deep clone with circular reference handling * - `shallow`: Top-level only clone * - `structured`: Native `structuredClone` * * @example * ```ts * // Deep clone (default) * clone({ a: { b: 1 } }); * * // Shallow clone * clone({ a: { b: 1 } }, { strategy: 'shallow' }); * * // Structured clone * clone(new Map([[1, 2]]), { strategy: 'structured' }); * ``` */ export declare const clone: (value: T, opts?: CloneOptions) => T; export {};