js-compare
Comparison code bricks for JavaScript.
let compare = ; > 0 ; // true
Can be managed through jspm, duo, component, bower, ender, jam, spm, and npm.
Install
jspm
jspm install github:aureooms/js-compare# orjspm install npm:aureooms-js-compare
duo
No install step needed for duo!
component
component install aureooms/js-compare
bower
bower install aureooms-js-compare
ender
ender add aureooms-js-compare
jam
jam install aureooms-js-compare
spm
spm install aureooms-js-compare --save
npm
npm install aureooms-js-compare --save
Require
jspm
let compare = ;// or;
duo
let compare = ;
component, ender, spm, npm
let compare = ;
bower
The script tag exposes the global variable compare
.
Alternatively, you can use any tool mentioned here.
jam
;
Use
let increasing = compareincreasing ;let decreasing = comparedecreasing ; === 0 ; // true < 0 ; // true > 0 ; // true === 0 ; // true > 0 ; // true < 0 ; // true let lexicographical = compare ; === 0 ; // true < 0 ; // true > 0 ; // true < 0 ; // true > 0 ; // true > 0 ; // true < 0 ; // true let reverselexicographical = compare ; === 0 ; // true > 0 ; // true < 0 ; // true > 0 ; // true < 0 ; // true < 0 ; // true > 0 ; // true // ... and many more variants. /** compare backwards, if identical compare length */let increasing = compare ;/** compare length first, if identical compare forwards */let increasing = compare ;/** compare length first, if identical compare backwards */let increasing = compare ;/** compare components in range [0, 3[, forwards */let increasing = compare ;/** compare components in range [0, 3[, backwards */let increasing = compare ;/** compare components in range [1, 4[, forwards */let increasing = compare ;/** compare components in range [1, 4[, backwards */let increasing = compare ; // Also includes comparison function creation tools. Hereunder, all versions are equivalent.let operator = ;let increasing = compare ;let increasing = compare ;let increasing = compare ; // Plus an additional useful tool.compare === -1 ; // truecompare === 0 ; // truecompare === 1 ; // true