assign-defined
Advanced tools
Comparing version 1.0.0 to 1.0.1
29
index.js
@@ -1,30 +0,3 @@ | ||
var assign = require('object-assign') | ||
var assignFilter = require('assign-filter') | ||
function assignFilter(filter, target, ...args) { | ||
var args = Array.prototype.slice.call(arguments, 2) | ||
var filteredArgs = args.map(function(obj) { | ||
if (obj == null) { | ||
return obj | ||
} | ||
return Object.keys(obj).reduce(function(acc, propName) { | ||
var value = obj[propName] | ||
if (filter(value, propName, obj)) { | ||
acc[propName] = value | ||
} | ||
return acc | ||
}, {}) | ||
}) | ||
return assign.apply(null, [target].concat(filteredArgs)) | ||
} | ||
function isDefined(value) { | ||
return value !== undefined | ||
} | ||
module.exports = function(target) { | ||
@@ -31,0 +4,0 @@ var sources = Array.prototype.slice.call(arguments, 1) |
{ | ||
"name": "assign-defined", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "Object.assign that skips any undefined properties from source objects", | ||
@@ -27,4 +27,4 @@ "main": "index.js", | ||
"dependencies": { | ||
"object.assign": "^4.0.3" | ||
"assign-filter": "^1.0.0" | ||
} | ||
} |
# assign-defined | ||
Object.assign that skips any undefined properties from source objects | ||
## Install | ||
```sh | ||
$ npm i assign-defined --save | ||
``` | ||
## Usage | ||
```js | ||
var assignDefined = require('assign-defined') | ||
var target = {} | ||
//only copy defined properties | ||
assignFilter(target, { a: undefined, b: 1 }, { c: 2 }) | ||
//target is { b: 1, c: 2 } | ||
``` | ||
## License | ||
#### MIT |
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
Trivial Package
Supply chain riskPackages less than 10 lines of code are easily copied into your own project and may not warrant the additional supply chain risk of an external dependency.
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
6
26
3024
5
1
+ Addedassign-filter@^1.0.0
+ Addedassign-filter@1.0.2(transitive)
+ Addedobject-assign@4.1.1(transitive)
- Removedobject.assign@^4.0.3
- Removedcall-bind@1.0.8(transitive)
- Removedcall-bind-apply-helpers@1.0.1(transitive)
- Removedcall-bound@1.0.3(transitive)
- Removeddefine-data-property@1.1.4(transitive)
- Removeddefine-properties@1.2.1(transitive)
- Removeddunder-proto@1.0.1(transitive)
- Removedes-define-property@1.0.1(transitive)
- Removedes-errors@1.3.0(transitive)
- Removedes-object-atoms@1.0.0(transitive)
- Removedfunction-bind@1.1.2(transitive)
- Removedget-intrinsic@1.2.7(transitive)
- Removedget-proto@1.0.1(transitive)
- Removedgopd@1.2.0(transitive)
- Removedhas-property-descriptors@1.0.2(transitive)
- Removedhas-symbols@1.1.0(transitive)
- Removedhasown@2.0.2(transitive)
- Removedmath-intrinsics@1.1.0(transitive)
- Removedobject-keys@1.1.1(transitive)
- Removedobject.assign@4.1.7(transitive)
- Removedset-function-length@1.2.2(transitive)