
Security News
AGENTS.md Gains Traction as an Open Format for AI Coding Agents
AGENTS.md is a fast-growing open format giving AI coding agents a shared, predictable way to understand project setup, style, and workflows.
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.
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
AGENTS.md is a fast-growing open format giving AI coding agents a shared, predictable way to understand project setup, style, and workflows.
Security News
/Research
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
Security News
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.