UNPKG

@jsbits/deep-clone

Version:

Performs a deep cloning of an object own properties and symbols, with loosy or exact behavior.

28 lines 1.18 kB
/// <reference lib="es2015" /> /** * Performs a deep cloning of an object own properties and symbols, preserving * its prototype. * * By default `cloneObject` works in "loosy mode", where it clones only * the object _enumerable_ properties and symbols. * * To enable the "exact mode" and clone all, pass `true` in the second parameter. * * Both modes retain all the attributes of the copied properties (enumerable, * configurable, writable) and correctly transfer the `get` and/or `set` * methods, although these, like the other function-type values, * _are copied by reference_. * * Try to limit the usage of this function to POJOs, as this function does not * work for objects with constructor that requires parameters (other than * the most JS built-in Objects), nor objects with recursive references. * * @template T * @param {T} value Value to clone, mostly an object or array. * @param {boolean} [exact=false] If `true`, also clone the non-enumerable properties * @returns {T} The cloned object or value. * @since 1.0.0 */ declare const deepClone: <T>(value: T, exact?: boolean | undefined) => T; export = deepClone; //# sourceMappingURL=index.d.ts.map