Migrate core/utils/math.js to goog.module

This commit is contained in:
kozbial
2021-07-14 10:45:45 -07:00
committed by Monica Kozbial
parent 5fbf5fe40d
commit 06cbde1dba
2 changed files with 8 additions and 6 deletions

View File

@@ -16,7 +16,8 @@
* @name Blockly.utils.math
* @namespace
*/
goog.provide('Blockly.utils.math');
goog.module('Blockly.utils.math');
goog.module.declareLegacyNamespace();
/**
@@ -25,7 +26,7 @@ goog.provide('Blockly.utils.math');
* @param {number} angleDegrees Angle in degrees.
* @return {number} Angle in radians.
*/
Blockly.utils.math.toRadians = function(angleDegrees) {
const toRadians = function(angleDegrees) {
return angleDegrees * Math.PI / 180;
};
@@ -35,7 +36,7 @@ Blockly.utils.math.toRadians = function(angleDegrees) {
* @param {number} angleRadians Angle in radians.
* @return {number} Angle in degrees.
*/
Blockly.utils.math.toDegrees = function(angleRadians) {
const toDegrees = function(angleRadians) {
return angleRadians * 180 / Math.PI;
};
@@ -46,7 +47,7 @@ Blockly.utils.math.toDegrees = function(angleRadians) {
* @param {number} upperBound The desired upper bound.
* @return {number} The clamped number.
*/
Blockly.utils.math.clamp = function(lowerBound, number, upperBound) {
const clamp = function(lowerBound, number, upperBound) {
if (upperBound < lowerBound) {
const temp = upperBound;
upperBound = lowerBound;
@@ -54,3 +55,5 @@ Blockly.utils.math.clamp = function(lowerBound, number, upperBound) {
}
return Math.max(lowerBound, Math.min(number, upperBound));
};
exports = {toRadians, toDegrees, clamp};