@teamteanpm2024/eveniet-nihil-dolores
v1.1.5
Published
<a href="https://www.npmjs.com/package/@teamteanpm2024/eveniet-nihil-dolores">![GitHub package.json version](https://img.shields.io/github/package-json/v/ichernetskii/@teamteanpm2024/eveniet-nihil-dolores?logo=npm)</a> <a href="https://bundlephobia.com/pa
Downloads
5
Maintainers
Keywords
Readme
Deeply-Clone
Deep fast clone JavaScript objects with circular references handling and TypeScript support
Installation
# Install with npm
npm install @teamteanpm2024/eveniet-nihil-dolores
# Install with yarn
yarn add @teamteanpm2024/eveniet-nihil-dolores
Usage
Once the package is installed, you can import the library using import or require approach:
import { deeplyClone } from "@teamteanpm2024/eveniet-nihil-dolores";
or
const deeplyClone = require("@teamteanpm2024/eveniet-nihil-dolores");
Features
- Clones deeply objects
- Supports Object, Array, Map or Set cloning
- Objects can have any circular references
- Fast algorithm with caching
- Strongly typed merged result with TypeScript
- No dependencies
- Small size
- Works in browser and Node.js
Examples
Objects
const book = {
title: "Harry Potter",
price: {
value: 69,
currency: "USD"
}
};
const bookCopy = deeplyClone(book);
console.log(bookCopy === book); // false
// const bookCopy = {
// title: "Harry Potter",
// price: {
// value: 69,
// currency: "USD"
// }
// };
Circular references
const book = {
title: "Harry Potter",
price: 49,
author: {
name: "Joanne Rowling",
books: [] // → [book]
}
};
book.author.books.push(book); // add circular reference
const bookCopy = deeplyClone(book);
console.log(bookCopy === book); // false
console.log(bookCopy.author.books[0] === bookCopy); // true
// const bookCopy = {
// title: "Harry Potter",
// price: 49,
// author: {
// name: "Joanne Rowling",
// books: [bookCopy] // circular reference → [bookCopy]
// }
// };