bool-comparison
v0.1.0
Published
Provides a simple short-hands for common comparisons
Downloads
5
Maintainers
Readme
bool-comparison
Provides simple short-hands for common comparisons
Requirements
- JavaScript ES6 for the use of rest parameters
Install
Install this package like any other packages:
npm install bool-comparisonUsage
Import this package like any other packages:
const compare = require('bool-comparison')This package contains documentation. You can check all functions and parameters' description in your IDE.
Compound Comparison
This package provide compound comparison functions that allow you to write less code to do same-variable comparisons
Each function in this category have the same signature:
x(value, strict, ...comp)Where:
xis the name of the functionvalueis the value to comparecompare all values to comparevaluewithstrictsets whether the comparisons are performed strictly (using===) or not (using==)
All of these functions compare all values in comp against value and returns true or false depending on the function.
compare.all(value, strict, ...comp)
Returns true only if all values in comp are equal to value
Internally, this function is equal to value ==(=) comp[0] && value ==(=) comp[1] && value ==(=) comp[2]...
compare.some(value, strict, ...comp)
Returns true if any values in comp are equal to value
Internally, this function is equal to value ==(=) comp[0] || value ==(=) comp[1] || value ==(=) comp[2]...
compare.none(value, strict, ...comp)
Returns true only if all values in comp are not equal to value
It is the negated form of compare.all
compare.notSome(value, strict, ...comp)
Returns true only if any values in comp are not equal to value
It is the negated form of compare.some
Numerical Comparison
This package provide functions to compare numerical data
compare.between(value, max, min, options)
Under construction
