@extra-map/compare.min

Compares two maps.

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
@extra-map/compare.min
312.2.152 years ago2 years agoMinified + gzip package size for @extra-map/compare.min in KB

Readme

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

This is part of package extra-map.

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



map.compare(x, y, [fc], [fm]);
// x:  a map
// y:  another map
// fc: compare function (a, b)
// fm: map function (v, k, x)
// → x=y: 0, otherwise: -ve/+ve

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

var x = new Map([["a", 1], ["b", 2]]);
var y = new Map([["a", 1], ["b", 2], ["c", 3]]);
map.compare(x, y);
// -1

var y = new Map([["a", 1], ["b", 2]]);
map.compare(x, y);
// 0

var y = new Map([["a", 1], ["b", -2]]);
map.compare(x, y);
// 1

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

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



References