Last active
January 30, 2018 22:58
-
-
Save sbrl/a725e32f14a3e4b94810 to your computer and use it in GitHub Desktop.
[Range.js] A very simple range class. #es6 #module #microlibrary
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/******************************************************************************* | |
******************************* ES6 Range Class ******************************* | |
******************************************************************************* | |
* v0.2 | |
******************************************************************************* | |
* A very simple range class. | |
******************************************************************************* | |
* https://gist.github.com/sbrl/a725e32f14a3e4b94810 | |
* Author: Starbeamrainbowlabs <[email protected]> | |
* | |
* Changelog: | |
* v0.1 - 24th Jan 2015: | |
* Uploaded to GitHub Gist. | |
* v0.2 | |
* Added ES6 module export syntax. | |
* Added range calculated parameter. | |
*/ | |
/// [email protected] by Starbeamrainbowlabs /// | |
class Range | |
{ | |
constructor(inMin, inMax) { | |
if(inMin > inMax) | |
throw new Error(`Min is bigger than max! (min: ${inMin}, max: ${inMax})`); | |
this.min = inMin; | |
this.max = inMax; | |
} | |
/** | |
* Calculates and returns the fistance between the maximum and the minimum. | |
* @return {number} The distance between the maximum and the minimum. | |
*/ | |
get range() | |
{ | |
return this.max - this.min; | |
} | |
} | |
export default Range; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment