/** * Python copy module for TypeScript * * Provides shallow and deep copy operations. * * @see {@link https://docs.python.org/3/library/copy.html | Python copy documentation} * @module */ /** * Create a shallow copy of an object. * * For primitive types, returns the value as-is. * For arrays, returns a new array with the same elements. * For objects, returns a new object with the same properties. * For Maps and Sets, returns new instances with the same entries. * * @param x - The object to copy * @returns A shallow copy of x * * @example * ```typescript * const original = [1, [2, 3], 4] * const copied = copy(original) * copied[0] = 99 * console.log(original[0]) // 1 (unchanged) * copied[1][0] = 99 * console.log(original[1][0]) // 99 (nested array is shared) * ``` */ declare function copy(x: T): T; /** * Create a deep copy of an object. * * Creates a complete independent copy of the object and all nested objects. * Uses structuredClone when available, with a fallback for older environments. * * Note: Functions cannot be deep copied and will be shared between copies. * * @param x - The object to deep copy * @param memo - Internal map for circular reference handling (optional) * @returns A deep copy of x * * @example * ```typescript * const original = { a: 1, b: { c: 2 } } * const copied = deepcopy(original) * copied.b.c = 99 * console.log(original.b.c) // 2 (unchanged) * ``` */ declare function deepcopy(x: T, memo?: Map): T; declare const copyModule_copy: typeof copy; declare const copyModule_deepcopy: typeof deepcopy; declare namespace copyModule { export { copyModule_copy as copy, copyModule_deepcopy as deepcopy }; } export { copy as a, copyModule as c, deepcopy as d };