Plato on Github
Report Home
core/clamp.js
Maintainability
101.16
Lines of code
31
Difficulty
30.47
Estimated Errors
0.19
Function weight
By Complexity
By SLOC
define('clamp', function() { var clamp = function(value, min, max) { var _ref, _ref1, _ref2; if ( typeof value === 'object') { _ref = value, min = _ref.min, max = _ref.max, value = _ref.value; } if (Array.isArray(min)) { _ref1 = min, min = _ref1[0], max = _ref1[1]; } if (min == null) { min = 0.0; } if (max == null) { max = 1.0; } if (min > max) { _ref2 = [max, min], min = _ref2[0], max = _ref2[1]; } if ((min <= value && value <= max)) { return value; } else { if (value > max) { return max; } else { return min; } } }; return clamp; });