Socket
Socket
Sign inDemoInstall

copy-anything

Package Overview
Dependencies
Maintainers
1
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

copy-anything

An optimised way to copy'ing an object. A small and simple integration


Version published
Weekly downloads
6M
decreased by-5.15%
Maintainers
1
Weekly downloads
 
Created

What is copy-anything?

The 'copy-anything' npm package is a utility for deep cloning JavaScript objects, arrays, and other data types. It ensures that the copied data is a completely new instance, preventing unintended mutations in the original data.

What are copy-anything's main functionalities?

Deep Cloning Objects

This feature allows you to create a deep clone of an object, ensuring that nested objects are also cloned and not just referenced.

const copy = require('copy-anything');
const original = { a: 1, b: { c: 2 } };
const cloned = copy(original);
console.log(cloned); // { a: 1, b: { c: 2 } }

Deep Cloning Arrays

This feature allows you to create a deep clone of an array, ensuring that nested arrays and objects within the array are also cloned.

const copy = require('copy-anything');
const originalArray = [1, [2, 3], { a: 4 }];
const clonedArray = copy(originalArray);
console.log(clonedArray); // [1, [2, 3], { a: 4 }]

Handling Special Data Types

This feature ensures that special data types like Date objects are properly cloned, creating new instances with the same values.

const copy = require('copy-anything');
const original = new Date();
const cloned = copy(original);
console.log(cloned); // A new Date instance with the same value as original

Other packages similar to copy-anything

Keywords

FAQs

Package last updated on 05 Jun 2024

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc