UNPKG

@bemedev/types

Version:

Type definitions for Bemedev projects

17 lines 1.12 kB
import type { PrimitiveObject } from '../types/types'; export type FormatKey<T = any> = (key: Extract<keyof T, string>) => string; /** * Creates a deep clone of an object or array, preserving its structure and values. * * * @param value of type {@linkcode PrimitiveObject} The value to deep clone, which can be an object, array, or primitive. * @param formatKey A function to format the keys of the cloned object. If not provided, keys will remain unchanged. * @param refs A map to keep track of already cloned objects to handle circular references. * This is used to prevent infinite loops when cloning objects that reference each other. * @returns A deep clone of the input value, preserving the structure and values of the original object or array. * * Inspired by the `deep-clone` npm {@link https://www.npmjs.com/package/deep-clone|library}, * @see the {@link https://github.com/thebearingedge/deep-clone/blob/main/src/deep-clone.ts|implementation} for more details. */ export default function deepClone<I extends PrimitiveObject>(value: I, refs?: Map<I, I>): I; //# sourceMappingURL=deepclone.d.ts.map