4 * Copyright(c) 2006-2007, Ext JS, LLC.
6 * Originally Released Under LGPL - original licence link has changed is not relivant.
9 * <script type="text/javascript">
15 Roo.applyIf(Number.prototype, {
17 * Checks whether or not the current number is within a desired range. If the number is already within the
18 * range it is returned, otherwise the min or max value is returned depending on which side of the range is
19 * exceeded. Note that this method returns the constrained value but does not change the current number.
20 * @param {Number} min The minimum number in the range
21 * @param {Number} max The maximum number in the range
22 * @return {Number} The constrained value if outside the range, otherwise the current value
24 constrain : function(min, max){
25 return Math.min(Math.max(this, min), max);