common-objects-in-arrays

1.0.7 • Public • Published

common-objects-in-arrays

Can use this package to find out the common objects in between the n number of arrays and on the basis of n number of keys

Install

npm install --save common-objects-in-arrays

Usage

const testModule = require('common-objects-in-arrays');

let firstArray = [ { "id":"test", "displayName" : "Test" } { "id":"demo", "displayName" : "Demo" } ]; let secondArray = [ { "id" : "test", "displayName" : "Test" } ]; let thirdArray = [ { "id" : "test", "displayName" : "Test" }, { "id" : "user", "displayName" : "User" } ] testModule.findCommonObjectsOfArrays(["id"], firstArray, secondArray, thirdArray);

//result will be [ { "key" : "test", "displayName" : "Test" } ]

When we compare all the objects in each and every array on the basis key id that is mentioned in the first parameter of findIntersectionOfArray, test id is common in all the arrays. So the result will have this object.

You can pass any number of keys in the first parameter in array format. Also you can any number of arrays from second parameter onwards

Package Sidebar

Install

npm i common-objects-in-arrays

Weekly Downloads

0

Version

1.0.7

License

ISC

Unpacked Size

3.01 kB

Total Files

3

Last publish

Collaborators

  • pradeepaanumalla