Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

clone-deep

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

clone-deep - npm Package Compare versions

Comparing version 0.2.4 to 0.3.0

16

index.js

@@ -7,3 +7,6 @@ 'use strict';

var utils = require('./utils');
var isObject = require('is-plain-object');
var clone = require('shallow-clone');
var typeOf = require('kind-of');
var forOwn = require('for-own');

@@ -15,3 +18,3 @@ /**

function cloneDeep(val, instanceClone) {
switch (utils.typeOf(val)) {
switch (typeOf(val)) {
case 'object':

@@ -21,4 +24,5 @@ return cloneObjectDeep(val, instanceClone);

return cloneArrayDeep(val, instanceClone);
default:
return utils.clone(val);
default: {
return clone(val);
}
}

@@ -28,5 +32,5 @@ }

function cloneObjectDeep(obj, instanceClone) {
if (utils.isObject(obj)) {
if (isObject(obj)) {
var res = {};
utils.forOwn(obj, function(obj, key) {
forOwn(obj, function(obj, key) {
this[key] = cloneDeep(obj, instanceClone);

@@ -33,0 +37,0 @@ }, res);

{
"name": "clone-deep",
"description": "Recursively (deep) clone JavaScript native types, like Object, Array, RegExp, Date as well as primitives.",
"version": "0.2.4",
"version": "0.3.0",
"homepage": "https://github.com/jonschlinkert/clone-deep",

@@ -13,4 +13,3 @@ "author": "Jon Schlinkert (https://github.com/jonschlinkert)",

"files": [
"index.js",
"utils.js"
"index.js"
],

@@ -25,11 +24,10 @@ "main": "index.js",

"dependencies": {
"for-own": "^0.1.3",
"for-own": "^1.0.0",
"is-plain-object": "^2.0.1",
"kind-of": "^3.0.2",
"lazy-cache": "^1.0.3",
"kind-of": "^3.2.2",
"shallow-clone": "^0.1.2"
},
"devDependencies": {
"mocha": "*",
"should": "*"
"gulp-format-md": "^0.1.12",
"mocha": "^3.4.1"
},

@@ -62,9 +60,14 @@ "keywords": [

"verb": {
"related": {
"list": []
},
"toc": false,
"layout": "default",
"tasks": [
"readme"
],
"plugins": [
"gulp-format-md"
]
],
"lint": {
"reflinks": true
}
}
}

@@ -1,13 +0,11 @@

# clone-deep [![NPM version](https://img.shields.io/npm/v/clone-deep.svg)](https://www.npmjs.com/package/clone-deep) [![Build Status](https://img.shields.io/travis/jonschlinkert/clone-deep.svg)](https://travis-ci.org/jonschlinkert/clone-deep)
# clone-deep [![NPM version](https://img.shields.io/npm/v/clone-deep.svg?style=flat)](https://www.npmjs.com/package/clone-deep) [![NPM monthly downloads](https://img.shields.io/npm/dm/clone-deep.svg?style=flat)](https://npmjs.org/package/clone-deep) [![NPM total downloads](https://img.shields.io/npm/dt/clone-deep.svg?style=flat)](https://npmjs.org/package/clone-deep) [![Linux Build Status](https://img.shields.io/travis/jonschlinkert/clone-deep.svg?style=flat&label=Travis)](https://travis-ci.org/jonschlinkert/clone-deep)
> Recursively (deep) clone JavaScript native types, like Object, Array, RegExp, Date as well as primitives.
The `instanceClone` function is invoked to clone objects that are not "plain" objects (as defined by [](#isPlainObject)`isPlainObject`) if it is provided. If `instanceClone` is not specified, it will not attempt to clone non-plain objects, and will copy the object reference.
## Install
Install with [npm](https://www.npmjs.com/)
Install with [npm](https://www.npmjs.com/):
```sh
$ npm i clone-deep --save
$ npm install --save clone-deep
```

@@ -33,41 +31,48 @@

## Other object utils
## Heads up!
* [assign-deep](https://www.npmjs.com/package/assign-deep): Deeply assign the enumerable properties and/or es6 Symbol properies of source objects to the target… [more](https://www.npmjs.com/package/assign-deep) | [homepage](https://github.com/jonschlinkert/assign-deep)
* [extend-shallow](https://www.npmjs.com/package/extend-shallow): Extend an object with the properties of additional objects. node.js/javascript util. | [homepage](https://github.com/jonschlinkert/extend-shallow)
* [merge-deep](https://www.npmjs.com/package/merge-deep): Recursively merge values in a javascript object. | [homepage](https://github.com/jonschlinkert/merge-deep)
* [mixin-deep](https://www.npmjs.com/package/mixin-deep): Deeply mix the properties of objects into the first object. Like merge-deep, but doesn't clone. | [homepage](https://github.com/jonschlinkert/mixin-deep)
* [mixin-object](https://www.npmjs.com/package/mixin-object): Mixin the own and inherited properties of other objects onto the first object. Pass an… [more](https://www.npmjs.com/package/mixin-object) | [homepage](https://github.com/jonschlinkert/mixin-object)
* [shallow-clone](https://www.npmjs.com/package/shallow-clone): Make a shallow clone of an object, array or primitive. | [homepage](https://github.com/jonschlinkert/shallow-clone)
The `instanceClone` function is invoked to clone objects that are not "plain" objects (as defined by [isPlainObject](#isPlainObject)`isPlainObject`) if it is provided. If `instanceClone` is not specified, it will not attempt to clone non-plain objects, and will copy the object reference.
## Running tests
## Attribution
Install dev dependencies:
Based on [mout's](https://github.com/mout/mout) implementation of deepClone.
## About
### Contributing
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).
### Building docs
_(This project's readme.md is generated by [verb](https://github.com/verbose/verb-generate-readme), please don't edit the readme directly. Any changes to the readme must be made in the [.verb.md](.verb.md) readme template.)_
To generate the readme, run the following command:
```sh
$ npm i -d && npm test
$ npm install -g verbose/verb#dev verb-generate-readme && verb
```
## Contributing
### Running tests
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/jonschlinkert/clone-deep/issues/new).
Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:
## Author
```sh
$ npm install && npm test
```
### Author
**Jon Schlinkert**
* [github/jonschlinkert](https://github.com/jonschlinkert)
* [twitter/jonschlinkert](http://twitter.com/jonschlinkert)
* [twitter/jonschlinkert](https://twitter.com/jonschlinkert)
Based on [mout's](https://github.com/mout/mout) implementation of deepClone.
### License
## License
Copyright © 2017, [Jon Schlinkert](https://github.com/jonschlinkert).
Released under the [MIT License](LICENSE).
Copyright © 2014-2015 [Jon Schlinkert](https://github.com/jonschlinkert)
Released under the MIT license.
***
_This file was generated by [verb](https://github.com/verbose/verb) on December 23, 2015._
<!-- deps:helper-lookup-deps -->
_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.6.0, on May 19, 2017._

Sorry, the diff of this file is not supported yet

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