merge-descriptors
Advanced tools
Comparing version 0.0.2 to 1.0.0
55
index.js
@@ -1,3 +0,52 @@ | ||
module.exports = function (dest, src) { | ||
Object.getOwnPropertyNames(src).forEach(function (name) { | ||
/*! | ||
* merge-descriptors | ||
* Copyright(c) 2014 Jonathan Ong | ||
* MIT Licensed | ||
*/ | ||
/** | ||
* Module exports. | ||
* @public | ||
*/ | ||
module.exports = merge | ||
/** | ||
* Module variables. | ||
* @private | ||
*/ | ||
var hasOwnProperty = Object.prototype.hasOwnProperty | ||
/** | ||
* Merge the property descriptors of `src` into `dest` | ||
* | ||
* @param {object} dest Object to add descriptors to | ||
* @param {object} src Object to clone descriptors from | ||
* @param {boolean} [redefine=true] Redefine `dest` properties with `src` properties | ||
* @returns {object} Reference to dest | ||
* @public | ||
*/ | ||
function merge(dest, src, redefine) { | ||
if (!dest) { | ||
throw new TypeError('argument dest is required') | ||
} | ||
if (!src) { | ||
throw new TypeError('argument src is required') | ||
} | ||
if (redefine === undefined) { | ||
// Default to true | ||
redefine = true | ||
} | ||
Object.getOwnPropertyNames(src).forEach(function forEachOwnPropertyName(name) { | ||
if (!redefine && hasOwnProperty.call(dest, name)) { | ||
// Skip desriptor | ||
return | ||
} | ||
// Copy descriptor | ||
var descriptor = Object.getOwnPropertyDescriptor(src, name) | ||
@@ -8,2 +57,2 @@ Object.defineProperty(dest, name, descriptor) | ||
return dest | ||
} | ||
} |
{ | ||
"name": "merge-descriptors", | ||
"description": "Merge objects using descriptors", | ||
"version": "0.0.2", | ||
"version": "1.0.0", | ||
"author": { | ||
@@ -11,2 +11,5 @@ "name": "Jonathan Ong", | ||
}, | ||
"contributors": [ | ||
"Douglas Christopher Wilson <doug@somethingdoug.com>" | ||
], | ||
"license": "MIT", | ||
@@ -21,5 +24,7 @@ "repository": { | ||
}, | ||
"scripts": { | ||
"test": "make test;" | ||
} | ||
"files": [ | ||
"LICENSE", | ||
"README.md", | ||
"index.js" | ||
] | ||
} |
@@ -1,2 +0,2 @@ | ||
# Merge Descriptors [![Build Status](https://travis-ci.org/component/merge-descriptors.png)](https://travis-ci.org/component/merge-descriptors) | ||
# Merge Descriptors | ||
@@ -25,26 +25,11 @@ Merge objects using descriptors. | ||
Overwrites `destination`'s descriptors with `source`'s. | ||
Redefines `destination`'s descriptors with `source`'s. | ||
## License | ||
### merge(destination, source, false) | ||
The MIT License (MIT) | ||
Defines `source`'s descriptors on `destination` if `destination` does not have | ||
a descriptor by the same name. | ||
Copyright (c) 2013 Jonathan Ong me@jongleberry.com | ||
## License | ||
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, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. | ||
[MIT](LICENSE) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
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
3372
46
1
4
35
1