-
Notifications
You must be signed in to change notification settings - Fork 21
Helpers.intersect()
Javi Jiménez edited this page Jun 26, 2016
·
2 revisions
Returns if the intersection between two arrays is successful:
import { intersect } from 'ava-ia/lib/helpers';
const a = ['a', 'b', 'c'];
const b = [1, 'b', 2];
const nums = [1, 2, 3];
intersect(a, b);
// true
intersect(a, nums);
// false
intersect(b, c);
//true
'use strict';
export default (array1 = [], array2 = []) => {
return array1.filter(item => array2.indexOf(item) != -1).length > 0;
}
Feel free to offer new features, improvements or anything you can think of. This project makes sense with your participation and experience using Ava.