esnext.math.clamp.js 314 B

12345678910111213
  1. 'use strict';
  2. var $ = require('../internals/export');
  3. var min = Math.min;
  4. var max = Math.max;
  5. // `Math.clamp` method
  6. // https://rwaldron.github.io/proposal-math-extensions/
  7. $({ target: 'Math', stat: true, forced: true }, {
  8. clamp: function clamp(x, lower, upper) {
  9. return min(upper, max(lower, x));
  10. }
  11. });