@newdash/newdash
Version:
javascript/typescript utility library
35 lines (34 loc) • 1.02 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.cloneDeep = void 0;
const baseClone_1 = __importDefault(require("./.internal/baseClone"));
/** Used to compose bitmasks for cloning. */
const CLONE_DEEP_FLAG = 1;
const CLONE_SYMBOLS_FLAG = 4;
/**
* This method is like `clone` except that it recursively clones `value`.
* Object inheritance is preserved.
*
* @since 5.3.0
* @category Lang
* @param value The value to recursively clone.
* @returns Returns the deep cloned value.
* @see clone
* @example
*
* ```js
* const objects = [{ 'a': 1 }, { 'b': 2 }]
*
* const deep = cloneDeep(objects)
* console.log(deep[0] === objects[0])
* // => false
* ```
*/
function cloneDeep(value) {
return (0, baseClone_1.default)(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG);
}
exports.cloneDeep = cloneDeep;
exports.default = cloneDeep;