@extra-array/compare.min

Compares two arrays.

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
@extra-array/compare.min
1412.10.198 months ago3 years agoMinified + gzip package size for @extra-array/compare.min in KB

Readme

Compares two arrays. :package: :smileycat: :running: :vhs: :moon: :scroll: :newspaper: :bluebook:
Similar: compare, isEqual.

This is part of package extra-array.

This is browserified, minified version of @extra-array/compare.
It is exported as global variable arraycompare.
CDN: unpkg
, jsDelivr.



array.compare(x, y, [fc], [fm]);
// x:  an array
// y:  another array
// fc: compare function (a, b)
// fm: map function (v, i, x)
// → x<y: -1, x=y: 0, x>y: 1

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

var x = [1, 2];
var y = [1, 2, 3];
array.compare(x, y);
// -1

var y = [1, 2];
array.compare(x, y);
// 0

var y = [1, -2];
array.compare(x, y);
// 1

array.compare(x, y, (a, b) => Math.abs(a) - Math.abs(b));
// 0

array.compare(x, y, null, v => Math.abs(v));
// 0



References