Socket
Socket
Sign inDemoInstall

object-lib

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

object-lib - npm Package Compare versions

Comparing version 1.2.0 to 1.3.0

lib/core/merge.js

5

lib/index.js

@@ -7,5 +7,8 @@ "use strict";

const Merge = require('./core/merge');
module.exports = {
align,
contain
contain,
Merge
};

6

package.json
{
"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 } ] }
```
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