react-native/Libraries/Utilities/clamp.js

31 lines
625 B
JavaScript
Raw Normal View History

2015-03-25 02:34:12 +00:00
/**
* Copyright (c) 2015-present, Facebook, Inc.
* All rights reserved.
2015-03-25 02:34:12 +00:00
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
2015-03-25 02:34:12 +00:00
*
* @providesModule clamp
* @typechecks
*/
'use strict';
2015-03-25 02:34:12 +00:00
/**
* @param {number} value
* @param {number} min
* @param {number} max
* @return {number}
*/
2015-03-25 02:34:12 +00:00
function clamp(min, value, max) {
if (value < min) {
return min;
}
if (value > max) {
return max;
}
return value;
}
module.exports = clamp;