1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-20 08:07:59 +01:00

Add util.Math.constrain.

This commit is contained in:
Doug Kearns
2009-05-30 20:29:23 +10:00
parent 3e984c776d
commit 95dffaf95a
5 changed files with 27 additions and 14 deletions

View File

@@ -387,6 +387,23 @@ const util = { //{{{
return ary;
},
/**
* Math utility methods.
* @singleton
*/
Math: {
/**
* Returns the specified <b>value</b> constrained to the range <b>min</b> -
* <b>max</b>.
*
* @param {number} value The value to constrain.
* @param {number} min The minimum constraint.
* @param {number} max The maximum constraint.
* @returns {number}
*/
constrain: function constrain(value, min, max) Math.min(Math.max(min, value), max),
},
/**
* Converts a URI string into a URI object.
*