consists

v2.0.0
Test if arrays consist of the same members.
consists array unordered compare equal lodash

Consists NPM version Build status

Test if arrays consist of the same members. Handles:

  • 2 or more arrays
  • arrays with multiple equivalent values
  • primitive & non-primitive array value types (uses SameValueZero for equality comparisons)
  • NaN values
import consists from 'consists';

consists([1,1,2,3], [3,1,2,1], [2,1,3,1]);
// => true

consists([1,1,2,3], [3,1,2]);
// => false

const a = { a: 'a' };
const b = { b: 'b' };
const c = { c: 'c' };
const a2 = { a: 'a' };

consists([a, b, c], [c, a, b]);
// => true

consists([a, b, c], [a2, b, c]);
// => false

Installation

npm i --save consists

Usage

import consists from 'consists';

consists([1,1,2,3], [3,1,2,1], [2,1,3,1]);
// => true

Lodash mixin:

import _ from 'lodash';
import consists from 'consists';

_.mixin({consists});
_.consists([1,1,2,3], [3,1,2,1], [2,1,3,1]);
// => true

License

MIT

npm i consists

Metadata

  • MIT
  • Whatever
  • Jeff Hanson
  • released 2/1/2017

Downloads

Maintainers