object-lib
Advanced tools
Comparing version 1.2.0 to 1.3.0
@@ -7,5 +7,8 @@ "use strict"; | ||
const Merge = require('./core/merge'); | ||
module.exports = { | ||
align, | ||
contain | ||
contain, | ||
Merge | ||
}; |
{ | ||
"name": "object-lib", | ||
"version": "1.2.0", | ||
"version": "1.3.0", | ||
"main": "lib/index.js", | ||
@@ -28,2 +28,3 @@ "repository": { | ||
"js-gardener": "2.0.184", | ||
"node-tdd": "2.19.1", | ||
"nyc": "15.1.0", | ||
@@ -109,3 +110,6 @@ "semantic-release": "17.3.7" | ||
"node": ">= 10" | ||
}, | ||
"dependencies": { | ||
"object-scan": "13.8.0" | ||
} | ||
} |
@@ -18,2 +18,4 @@ # object-lib | ||
For more extensive examples, please refer to the tests. | ||
### align(obj: Object, ref: Object) | ||
@@ -37,2 +39,14 @@ | ||
Check if `subtree` is contained in `tree` recursively. | ||
Different types are never considered _contained_. | ||
Arrays are _contained_ iff they are the same length and every | ||
element is _contained_ in the corresponding element. | ||
Objects are _contained_ if the keys are a subset, | ||
and the respective values are _contained_. | ||
All other types are contained if they match exactly (`===`). | ||
_Example:_ | ||
@@ -49,1 +63,27 @@ <!-- eslint-disable import/no-unresolved --> | ||
``` | ||
### Merge(logic: Object = {})(...obj: Object[]) | ||
Allows merging of objects. The logic defines paths that map to a field, or a function, to merge by. | ||
If a function is passed, it is invoked with the value, and the result is used as the merge identifier. | ||
The paths are defined using [object-scan](https://github.com/blackflux/object-scan) syntax. | ||
_Example:_ | ||
<!-- eslint-disable import/no-unresolved --> | ||
```js | ||
const { Merge } = require('object-lig'); | ||
Merge()( | ||
{ children: [{ id: 1 }, { id: 2 }] }, | ||
{ children: [{ id: 2 }, { id: 3 }] } | ||
); | ||
// => { children: [ { id: 1 }, { id: 2 }, { id: 2 }, { id: 3 } ] } | ||
Merge({ '**[*]': 'id' })( | ||
{ children: [{ id: 1 }, { id: 2 }] }, | ||
{ children: [{ id: 2 }, { id: 3 }] } | ||
); | ||
// => { children: [ { id: 1 }, { id: 2 }, { id: 3 } ] } | ||
``` |
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
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
11058
7
139
87
1
19
+ Addedobject-scan@13.8.0
+ Addedobject-scan@13.8.0(transitive)