1
0
Derivar 0
Não pode escolher mais do que 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
Sven Slootweg 4963375faf 1.0.1 há 4 anos
README.md Initial commit há 4 anos
example.js Initial commit há 4 anos
index.js Initial commit há 4 anos
package.json 1.0.1 há 4 anos

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).