set-comparision
v1.0.2
Published
Compare two Sets by comparing elements' existences
Downloads
9
Maintainers
Readme
set-comparision
Language
ECMAScript 6
Usage
Import
Normal
const compare = require('set-comparision') // Equivalent to `template(template.OBJECT_EQUAL)`, see below
Advanced
const template = require('set-comparision/x')
const compare = template(myEqualFunction)
Functions
A
andB
are instances of aSet
-like classa
andb
are elements ofA
andB
above
compare(A, B)
Equivalent to compare.equal(A, B)
compare.equal(A, B)
Returns true
if every elements of A
are found in B
and vice versa
compare.subset(A, B)
Returns true
if A
is a subset of B
compare.superset(A, B)
Returns true
if A
is a superset of B
compare.notFunc(A, B)
- with
Func
is eitherEqual
,Subset
orSuperset
Returns negative boolean of compare.func(A, B)
, e.g. compare.notEqual(A, B)
is !compare.equal(A, B)
compare.xCompareSet(myEqualFunction)
Create a new set of set-comparision functions based on myEqualFunction
as element equality function
myEqualFunction
takes 2 parameters, which are a
and b
, and returns a boolean which true
for equal and false
otherwise
Equivalent to template(myEqualFunction)
with template = require('set-comparision/x')
compare.for(myEqualFunction)
Equivalent to compare.xCompareSet(myEqualFunction)
compare.STRICT_EQUAL(a, b)
compare.STRICT_EQUAL = (a, b) => a === b
compare.OBJECT_EQUAL(a, b)
compare.OBJECT_EQUAL = (a, b) => Object.is(a, b)
License
MIT