intersection

Type:Function
Status:stable
Since:1.0.0
Platform:jsnode
@blackbyte.sugar.shared.array

This function take two arrays and return all the items that are the same. You can specify if you want only comparing by reference for object, etc… or if you want to transform items in hashes and compare that instead.

Params

  1. …arrays*-Array

    The arrays you want to compare

  2. settings{}Object

    Some settings to refine your comparaison process

Return

  1. -Array

    An array containing all the items that are present in all the passed arrays

Example

import { intersection } from '@blackbyte/sugar/array';
intersection([1,2,3,4], [1,3,5]); // => [1,3]

Settings

  1. referencestrueBoolean

    Specify if you want to use the references comparaison or not

  2. hashtrueBoolean

    Specify if you want to allows transforming object etc in to hashes and compare this instead