https://github.com/jojoee/object.intersect
:tada: Return intersect object that have same key from a number of objects
https://github.com/jojoee/object.intersect
array-manipulations fast intersect intersection key object property
Last synced: 3 months ago
JSON representation
:tada: Return intersect object that have same key from a number of objects
- Host: GitHub
- URL: https://github.com/jojoee/object.intersect
- Owner: jojoee
- License: mit
- Created: 2018-01-08T14:21:59.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2019-07-17T23:39:50.000Z (almost 6 years ago)
- Last Synced: 2025-03-26T05:51:10.154Z (4 months ago)
- Topics: array-manipulations, fast, intersect, intersection, key, object, property
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/object.intersect
- Size: 11.7 KB
- Stars: 5
- Watchers: 1
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# object.intersect
[](https://travis-ci.org/jojoee/object.intersect)
[](https://david-dm.org/jojoee/object.intersect)
[](https://codecov.io/github/jojoee/object.intersect)
[](https://www.npmjs.com/package/object.intersect)
[](http://opensource.org/licenses/MIT)
[](https://github.com/semantic-release/semantic-release) [](https://greenkeeper.io/)Fast object.intersect key / PHP `array_intersect_key` with no dependencies
## Installation
```
// npm
npm install object.intersect
const intersect = require('object.intersect')
```## Example usage
```javascript
intersect() // {}
intersect({}) // {}
intersect(null) // {}
intersect(undefined) // {}const obj1 = { a: 'a', b: 'b', c: 'c' }
const obj2 = { a: 'a', b: 'x', c: 'c' }
const obj3 = { a: 'a', c: 'c' } // subset of obj
intersect(obj1, obj2) // { a: 'a', b: 'b', c: 'c' }
intersect(obj1, obj3, obj2) // { a: 'a', c: 'c' }
```## Reference
- [PHP: array_intersect_key - Manual](http://php.net/manual/en/function.array-intersect-key.php)