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:
@@ -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.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user