
Security News
Open Source CAI Framework Handles Pen Testing Tasks up to 3,600× Faster Than Humans
CAI is a new open source AI framework that automates penetration testing tasks like scanning and exploitation up to 3,600× faster than humans.
js-deep-clone
Advanced tools
A JavaScript module for deep cloning objects and arrays, with support for dates, while handling circular references.
Deep Clone Utility is a JavaScript function that performs a deep cloning of an object or array, supporting Date objects. It handles circular references to avoid infinite recursion.
Date
objects, ensuring accurate type preservation.WeakMap
.npm install js-deep-clone
To use the deepClone
function, you can import it from the file where it is defined:
import { deepClone } from 'js-deep-clone';
deepClone(input, map = new WeakMap())
input
: The object or array you want to deeply clone.map
: (optional): An instance of WeakMap used internally to track circular references.The function returns a deeply cloned copy of the input
object or array.
import { deepClone } from 'js-deep-clone';
const original = {
name: "Alice",
birthDate: new Date(),
friends: ["Bob", "Charlie"],
meta: { isActive: true }
};
// Creating a circular reference
original.self = original;
const cloned = deepClone(original);
console.log(cloned);
console.log(cloned !== original); // true - cloned is a new object
console.log(cloned.birthDate instanceof Date); // true - Date is preserved
console.log(cloned.self === cloned); // true - circular reference preserved
The deepClone function handles cloning as follows:
If the function encounters a data type it does not support, it will throw an error: 'Unsupported data type.'
No external dependencies are required. The function is implemented in pure JavaScript.
This project is licensed under the MIT License.
FAQs
A JavaScript module for deep cloning objects and arrays, with support for dates, while handling circular references.
The npm package js-deep-clone receives a total of 1 weekly downloads. As such, js-deep-clone popularity was classified as not popular.
We found that js-deep-clone demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
CAI is a new open source AI framework that automates penetration testing tasks like scanning and exploitation up to 3,600× faster than humans.
Security News
Deno 2.4 brings back bundling, improves dependency updates and telemetry, and makes the runtime more practical for real-world JavaScript projects.
Security News
CVEForecast.org uses machine learning to project a record-breaking surge in vulnerability disclosures in 2025.