UNPKG

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