Home
Docs
GitHub
Pricing
Blog
Log In

Run Sandworm Audit for your App

Get started
Hold on, we're currently generating a fresh version of this report
Generated on Mar 2, 2024 via pnpm

clone 1.0.4

deep cloning of objects and arrays
Package summary
Share
0
issues
1
license
1
MIT
Package created
3 Sep 2011
Version published
21 Mar 2018
Maintainers
1
Total deps
1
Direct deps
0
License
MIT

Issues

0
This package has no issues

Licenses

MIT License

Permissive
OSI Approved
This is a human-readable summary of (and not a substitute for) the license. Disclaimer.
Can
commercial-use
modify
distribute
sublicense
private-use
Cannot
hold-liable
Must
include-copyright
include-license
1 Packages, Including:
clone@1.0.4
Disclaimer

This deed highlights only some of the key features and terms of the actual license. It is not a license and has no legal value. You should carefully review all of the terms and conditions of the actual license before using the licensed material.

Sandworm is not a law firm and does not provide legal services. Distributing, displaying, or linking to this deed or the license that it summarizes does not create a lawyer-client or any other relationship.

Direct Dependencies

0
All Dependencies CSV
β“˜ This is a list of clone 's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.
NameVersionSizeLicenseTypeVulnerabilities

Visualizations

Frequently Asked Questions

What does clone do?

Clone is a npm package that provides foolproof deep cloning of JavaScript objects, arrays, numbers, strings, and other data types. It is capable of cloning simple objects (even those with custom prototypes), Date objects, and RegExp objects in a recursive manner. This means that even if you have complicated structures like arrays within objects containing dates, they would be cloned without any issues. If you're certain that your dataset does not contain circular references, you can even optimize clone's performance by using the circular setting.

How do you use clone?

Using the clone package is straightforward. To begin with, you need to install the package using npm with the following command: npm install clone. Once installed, you simply require the package in your JavaScript file. A simple usage example is demonstrated below:

var clone = require('clone');

var a, b;

a = { foo: { bar: 'baz' } };  // initial value of a

b = clone(a);                 // clone a to b
a.foo.bar = 'foo';            // change a

console.log(a);               // show a
console.log(b);               // show b

In the above code, we're creating an object a and cloning it into b using the clone function. Despite changes to object a after cloning, b remains unaffected, demonstrating the deep copy functionality.

Also note, clone supports circular references, where an object references itself:

var a, b;

a = { hello: 'world' };

a.myself = a;
b = clone(a);

console.log(b);

In this case, b.myself points to b, not a.

Where are the clone docs?

The documentation of the clone package can be found within the README file in the package's GitHub repository. The repository link is https://github.com/pvorb/node-clone. The README provides details on installation, examples on how to use clone, information on the package API, tips for handling circular references, and caveats for using the package. Please keep in mind that certain special objects (like a socket or process.stdout/stderr) are known to be uncloneable. It's always recommended to check the documentation for latest updates and issues.