Gathering detailed insights and metrics for clone
Gathering detailed insights and metrics for clone
Gathering detailed insights and metrics for clone
Gathering detailed insights and metrics for clone
npm install clone
Typescript
Module System
Min. Node Version
Node Version
NPM Version
100
Supply Chain
99.5
Quality
76
Maintenance
100
Vulnerability
100
License
JavaScript (82.13%)
HTML (17.87%)
Total Downloads
7,589,956,491
Last Day
1,960,837
Last Week
38,315,574
Last Month
165,120,979
Last Year
1,745,865,194
MIT License
786 Stars
225 Commits
132 Forks
15 Watchers
2 Branches
29 Contributors
Updated on Jun 28, 2025
Minified
Minified + Gzipped
Latest Version
2.1.2
Package Id
clone@2.1.2
Size
5.68 kB
NPM Version
3.9.3
Node Version
4.4.5
Published on
Mar 21, 2018
Cumulative downloads
Total Downloads
Last Day
-4.7%
1,960,837
Compared to previous day
Last Week
-7.2%
38,315,574
Compared to previous week
Last Month
-0.3%
165,120,979
Compared to previous month
Last Year
17.3%
1,745,865,194
Compared to previous year
1
offers foolproof deep cloning of objects, arrays, numbers, strings etc. in JavaScript.
npm install clone
(It also works with browserify, ender or standalone.)
1var clone = require('clone'); 2 3var a, b; 4 5a = { foo: { bar: 'baz' } }; // initial value of a 6 7b = clone(a); // clone a -> b 8a.foo.bar = 'foo'; // change a 9 10console.log(a); // show a 11console.log(b); // show b
This will print:
1{ foo: { bar: 'foo' } } 2{ foo: { bar: 'baz' } }
clone masters cloning simple objects (even with custom prototype), arrays, Date objects, and RegExp objects. Everything is cloned recursively, so that you can clone dates in arrays in objects, for example.
clone(val, circular, depth)
val
-- the value that you want to clone, any type allowed
circular
-- boolean
Call clone
with circular
set to false
if you are certain that obj
contains no circular references. This will give better performance if needed.
There is no error if undefined
or null
is passed as obj
.
depth
-- depth to which the object is to be cloned (optional,
defaults to infinity)
clone.clonePrototype(obj)
obj
-- the object that you want to cloneDoes a prototype clone as described by Oran Looney.
1var a, b; 2 3a = { hello: 'world' }; 4 5a.myself = a; 6b = clone(a); 7 8console.log(b);
This will print:
1{ hello: "world", myself: [Circular] }
So, b.myself
points to b
, not a
. Neat!
npm test
Some special objects like a socket or process.stdout
/stderr
are known to not
be cloneable. If you find other objects that cannot be cloned, please open an
issue.
If you encounter any bugs or issues, feel free to open an issue at github or send me an email to paul@vorba.ch. I also always like to hear from you, if you’re using my code.
Copyright © 2011-2015 Paul Vorbach and contributors.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
0 existing vulnerabilities detected
Reason
Found 6/20 approved changesets -- score normalized to 3
Reason
dependency not pinned by hash detected -- score normalized to 3
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2025-06-23
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More