Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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: about 2 months ago
JSON representation

:tada: Return intersect object that have same key from a number of objects

Awesome Lists containing this project

README

        

# object.intersect

[![Travis](https://img.shields.io/travis/jojoee/object.intersect.svg)](https://travis-ci.org/jojoee/object.intersect)
[![Dependency Status](https://david-dm.org/jojoee/object.intersect.svg)](https://david-dm.org/jojoee/object.intersect)
[![Codecov](https://img.shields.io/codecov/c/github/jojoee/object.intersect.svg)](https://codecov.io/github/jojoee/object.intersect)
[![Version - npm](https://img.shields.io/npm/v/object.intersect.svg)](https://www.npmjs.com/package/object.intersect)
[![License - npm](https://img.shields.io/npm/l/object.intersect.svg)](http://opensource.org/licenses/MIT)
[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg?style=flat-square)](https://github.com/semantic-release/semantic-release) [![Greenkeeper badge](https://badges.greenkeeper.io/jojoee/object.intersect.svg)](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)