shallow-clone
Advanced tools
Comparing version 0.1.2 to 1.0.0
15
index.js
/*! | ||
* shallow-clone <https://github.com/jonschlinkert/shallow-clone> | ||
* | ||
* Copyright (c) 2015, Jon Schlinkert. | ||
* Licensed under the MIT License. | ||
* Copyright (c) 2015-2017, Jon Schlinkert. | ||
* Released under the MIT License. | ||
*/ | ||
@@ -10,3 +10,5 @@ | ||
var utils = require('./utils'); | ||
var isObject = require('is-extendable'); | ||
var mixin = require('mixin-object'); | ||
var typeOf = require('kind-of'); | ||
@@ -21,4 +23,3 @@ /** | ||
function clone(val) { | ||
var type = utils.typeOf(val); | ||
var type = typeOf(val); | ||
if (clone.hasOwnProperty(type)) { | ||
@@ -39,4 +40,4 @@ return clone[type](val); | ||
clone.object = function cloneObject(obj) { | ||
if (utils.isObject(obj)) { | ||
return utils.mixin({}, obj); | ||
if (isObject(obj)) { | ||
return mixin({}, obj); | ||
} else { | ||
@@ -43,0 +44,0 @@ return obj; |
{ | ||
"name": "shallow-clone", | ||
"description": "Make a shallow clone of an object, array or primitive.", | ||
"version": "0.1.2", | ||
"version": "1.0.0", | ||
"homepage": "https://github.com/jonschlinkert/shallow-clone", | ||
"author": "Jon Schlinkert (https://github.com/jonschlinkert)", | ||
"contributors": [ | ||
"Brian Woodward (https://twitter.com/doowb)", | ||
"Jon Schlinkert (http://twitter.com/jonschlinkert)" | ||
], | ||
"repository": "jonschlinkert/shallow-clone", | ||
@@ -13,4 +17,3 @@ "bugs": { | ||
"files": [ | ||
"index.js", | ||
"utils.js" | ||
"index.js" | ||
], | ||
@@ -26,9 +29,9 @@ "main": "index.js", | ||
"is-extendable": "^0.1.1", | ||
"kind-of": "^2.0.1", | ||
"lazy-cache": "^0.2.3", | ||
"kind-of": "^5.0.0", | ||
"mixin-object": "^2.0.1" | ||
}, | ||
"devDependencies": { | ||
"mocha": "*", | ||
"should": "*" | ||
"gulp-format-md": "^1.0.0", | ||
"mocha": "^3.4.2", | ||
"should": "^11.2.1" | ||
}, | ||
@@ -46,13 +49,26 @@ "keywords": [ | ||
"verb": { | ||
"toc": false, | ||
"layout": "default", | ||
"tasks": [ | ||
"readme" | ||
], | ||
"plugins": [ | ||
"gulp-format-md" | ||
], | ||
"related": { | ||
"list": [ | ||
"assign-deep", | ||
"clone-deep", | ||
"extend-shallow", | ||
"is-plain-object", | ||
"mixin-object", | ||
"isobject", | ||
"kind-of", | ||
"mixin-deep", | ||
"extend-shallow", | ||
"assign-deep" | ||
"mixin-object" | ||
] | ||
}, | ||
"lint": { | ||
"reflinks": true | ||
} | ||
} | ||
} |
@@ -1,2 +0,2 @@ | ||
# shallow-clone [![NPM version](https://badge.fury.io/js/shallow-clone.svg)](http://badge.fury.io/js/shallow-clone) | ||
# shallow-clone [![NPM version](https://img.shields.io/npm/v/shallow-clone.svg?style=flat)](https://www.npmjs.com/package/shallow-clone) [![NPM monthly downloads](https://img.shields.io/npm/dm/shallow-clone.svg?style=flat)](https://npmjs.org/package/shallow-clone) [![NPM total downloads](https://img.shields.io/npm/dt/shallow-clone.svg?style=flat)](https://npmjs.org/package/shallow-clone) [![Linux Build Status](https://img.shields.io/travis/jonschlinkert/shallow-clone.svg?style=flat&label=Travis)](https://travis-ci.org/jonschlinkert/shallow-clone) | ||
@@ -7,6 +7,6 @@ > Make a shallow clone of an object, array or primitive. | ||
Install with [npm](https://www.npmjs.com/) | ||
Install with [npm](https://www.npmjs.com/): | ||
```sh | ||
$ npm i shallow-clone --save | ||
$ npm install --save shallow-clone | ||
``` | ||
@@ -60,37 +60,58 @@ | ||
## Related projects | ||
## About | ||
* [assign-deep](https://github.com/jonschlinkert/assign-deep): Deeply assign the enumerable properties of source objects to a destination object. | ||
* [clone-deep](https://github.com/jonschlinkert/clone-deep): Recursively (deep) clone JavaScript native types, like Object, Array, RegExp, Date as well as primitives. | ||
* [extend-shallow](https://github.com/jonschlinkert/extend-shallow): Extend an object with the properties of additional objects. node.js/javascript util. | ||
* [is-plain-object](https://github.com/jonschlinkert/is-plain-object): Returns true if an object was created by the `Object` constructor. | ||
* [mixin-object](https://github.com/jonschlinkert/mixin-object): Mixin the own and inherited properties of other objects onto the first object. Pass an… [more](https://github.com/jonschlinkert/mixin-object) | ||
* [mixin-deep](https://github.com/jonschlinkert/mixin-deep): Deeply mix the properties of objects into the first object. Like merge-deep, but doesn't clone. | ||
### Related projects | ||
## Running tests | ||
* [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://github.com/jonschlinkert/assign-deep) | [homepage](https://github.com/jonschlinkert/assign-deep "Deeply assign the enumerable properties and/or es6 Symbol properies of source objects to the target (first) object.") | ||
* [clone-deep](https://www.npmjs.com/package/clone-deep): Recursively (deep) clone JavaScript native types, like Object, Array, RegExp, Date as well as primitives. | [homepage](https://github.com/jonschlinkert/clone-deep "Recursively (deep) clone JavaScript native types, like Object, Array, RegExp, Date as well as primitives.") | ||
* [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 "Extend an object with the properties of additional objects. node.js/javascript util.") | ||
* [is-plain-object](https://www.npmjs.com/package/is-plain-object): Returns true if an object was created by the `Object` constructor. | [homepage](https://github.com/jonschlinkert/is-plain-object "Returns true if an object was created by the `Object` constructor.") | ||
* [isobject](https://www.npmjs.com/package/isobject): Returns true if the value is an object and not an array or null. | [homepage](https://github.com/jonschlinkert/isobject "Returns true if the value is an object and not an array or null.") | ||
* [kind-of](https://www.npmjs.com/package/kind-of): Get the native type of a value. | [homepage](https://github.com/jonschlinkert/kind-of "Get the native type of a value.") | ||
* [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 "Deeply mix the properties of objects into the first object. Like merge-deep, but doesn't clone.") | ||
* [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://github.com/jonschlinkert/mixin-object) | [homepage](https://github.com/jonschlinkert/mixin-object "Mixin the own and inherited properties of other objects onto the first object. Pass an empty object as the first arg to shallow clone.") | ||
Install dev dependencies: | ||
### Contributing | ||
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new). | ||
### Contributors | ||
| **Commits** | **Contributor** | | ||
| --- | --- | | ||
| 2 | [doowb](https://github.com/doowb) | | ||
| 2 | [jonschlinkert](https://github.com/jonschlinkert) | | ||
### 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/shallow-clone/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) | ||
* [github/jonschlinkert](https://github.com/jonschlinkert) | ||
* [twitter/jonschlinkert](https://twitter.com/jonschlinkert) | ||
## License | ||
### License | ||
Copyright © 2015 Jon Schlinkert | ||
Released under the MIT license. | ||
Copyright © 2017, [Jon Schlinkert](https://github.com/jonschlinkert). | ||
Released under the [MIT License](LICENSE). | ||
*** | ||
_This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on August 10, 2015._ | ||
_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.6.0, on July 16, 2017._ |
Sorry, the diff of this file is not supported yet
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
8791
3
0
115
0
0
3
4
47
+ Addedkind-of@5.1.0(transitive)
- Removedlazy-cache@^0.2.3
- Removedis-buffer@1.1.6(transitive)
- Removedkind-of@2.0.1(transitive)
- Removedlazy-cache@0.2.7(transitive)
Updatedkind-of@^5.0.0