Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.
 
Sven Slootweg 4963375faf 1.0.1 4 lat temu
README.md Initial commit 4 lat temu
example.js Initial commit 4 lat temu
index.js Initial commit 4 lat temu
package.json 1.0.1 4 lat temu

README.md

do-arrays-intersect

Checks only whether two given arrays intersect (ie. have values in common), but not what that intersection is exactly. This allows it to stop searching when it finds the first match, which can be much faster.

License, donations, and other boilerplate

Licensed under either the WTFPL or CC0, at your choice. In practice, that means it's more or less public domain, and you can do whatever you want with it. Giving credit is not required, but still very much appreciated! I'd love to hear from you if this module was useful to you.

Creating and maintaining open-source modules is a lot of work. A donation is also not required, but much appreciated! You can donate here.

Example

const doArraysIntersect = require("do-arrays-intersect");

let arrayA = [1, 3, 4, 6, 7, 8];
let arrayB = [2, 5, 6, 8, 9];

console.log(doArraysIntersect(arrayA, arrayB)); // true

let arrayC = [1, 3, 4, 6, 7, 8];
let arrayD = [2, 5, 9, 10, 11];

console.log(doArraysIntersect(arrayC, arrayD)); // false

API

doArraysIntersect(arrayA, arrayB)

Checks whether two arrays intersect. The equivalence function is ===, and custom equivalence functions are not currently supported; please file an issue if you need this!

The order that you specify the arrays in, does not matter.

  • arrayA: The first array.
  • arrayB: The second array.

Returns a boolean indicating whether an intersection was found (true) or not (false).