1.0.2 • Published 8 years ago
is-arrays-equal v1.0.2
is-arrays-equal
fast compare random order arrays with O(n) algorithm.
algorithm
[
example
var equal = require('is-arrays-equal');
console.dir([
equal(
[ 1, 2, 3 ],
[ 2, 3, 1 ]
),
equal(
[ -1, 2, 0 ],
[ 2, 0, -1 ]
),
equal(
[ 0, 0 ],
[ 0, 0 ]
),
equal(
[ 1.23, 2.34 ],
[ 2.34, 1.23 ]
),
equal(
[ {id: 1, text: 'id1'}, {id: 2, text: 'id2'} ],
[ {id: 2, text: 'id2'}, {id: 1, text: 'id1'} ],
function(obj) {
return obj.id;
}
)
]);
install
npm install is-arrays-equal
methods
var isArraysEqual = require('is-arrays-equal');
isArraysEqual(a, b, toUniqueId)
Compare array a
and b
, returning whether they are equal.
If the element in array is not Numeric
and toUniqueId
function is provided, toUniqueId
should return a Number
that represents a element in array.
license
MIT.