Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@extra-array/is-disjoint

nodef772MIT2.10.19TypeScript support: included

Checks if arrays have no value in common.

extra, array, is, disjoint, isDisjoint

readme

Checks if arrays have no value in common. :package: :smiley_cat: :running: :vhs: :moon: :scroll: :newspaper: :blue_book:

Similar: isUnique, isDisjoint, intersection.

This is part of package extra-array.


array.isDisjoint(x, y, [fc], [fm]);
// x:  an array
// y:  another array
// fc: compare function (a, b)
// fm: map function (v, i, x)

:stopwatch: Compare function => O(n²).

const array = require("extra-array");

var x = [1, 2, 3, 4];
array.isDisjoint(x, [2, 5]);
// false

array.isDisjoint(x, [-2, -5]);
// true

array.isDisjoint(x, [-2, -5], (a, b) => Math.abs(a) - Math.abs(b));
// false

array.isDisjoint(x, [-2, -5], null, v => Math.abs(v));
// false


References