fus-ext
Version:
FutureScript Extension
94 lines (92 loc) • 3.99 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.randomInt = exports.randomNumber = exports.roundDecimal = exports.principalDegrees = exports.principalRadians = exports.degreesToRadians = exports.radiansToDegrees = exports.approxLessThan = exports.approxGreaterThan = exports.approxEquals = undefined;
var _main = require("./main");
var dotDotCalc_573300145710716007 = function (dotDot, a, b, c) {
return dotDot(a)[b](a, ...c);
};var approxEquals, approxGreaterThan, approxLessThan, radiansToDegrees, degreesToRadians, principalRadians, principalDegrees, roundDecimal, randomNumber, randomInt;exports.approxEquals = approxEquals = function (ns, a, b) {
return (() => {
var threshold, ratioThreshold, var_573300145710716007_2;threshold = 1 / 8388608;ratioThreshold = 1 + threshold;return Math.abs(a) < threshold || Math.abs(b) < threshold ? (() => {
return Math.abs(a - b) < threshold;
})() : (() => {
return 1 / ratioThreshold < (var_573300145710716007_2 = a / b) && var_573300145710716007_2 < ratioThreshold;
})();
})();
};exports.approxGreaterThan = approxGreaterThan = function (ns, a, b) {
return (() => {
return a > b || dotDotCalc_573300145710716007(_main.dotDot_573300145710716007, Math, "approxEquals", [a, b]);
})();
};exports.approxLessThan = approxLessThan = function (ns, a, b) {
return (() => {
return a < b || dotDotCalc_573300145710716007(_main.dotDot_573300145710716007, Math, "approxEquals", [a, b]);
})();
};exports.radiansToDegrees = radiansToDegrees = function (ns, radians) {
return (() => {
return radians / Math.PI * 180;
})();
};exports.degreesToRadians = degreesToRadians = function (ns, degrees) {
return (() => {
return degrees / 180 * Math.PI;
})();
};exports.principalRadians = principalRadians = function (ns, radians) {
return (() => {
var t;t = radians % (2 * Math.PI);return t <= -Math.PI ? (() => {
return t + 2 * Math.PI;
})() : (() => {
return t > Math.PI ? (() => {
return t - 2 * Math.PI;
})() : (() => {
return t;
})();
})();
})();
};exports.principalDegrees = principalDegrees = function (ns, degrees) {
return (() => {
var t;t = degrees % 360;return t <= -180 ? (() => {
return t + 360;
})() : (() => {
return t > 180 ? (() => {
return t - 360;
})() : (() => {
return t;
})();
})();
})();
};exports.roundDecimal = roundDecimal = function (ns, x, digitCount) {
if (digitCount === undefined) {
digitCount = 0;
}return (() => {
var factor;factor = Math.pow(10, digitCount);return Math.round(x * factor) / factor;
})();
};exports.randomNumber = randomNumber = function (ns, m, n) {
return (() => {
return m < n ? (() => {
return m + Math.random() * (n - m);
})() : (() => {
return (0, _main.fail)();
})();
})();
};exports.randomInt = randomInt = function (ns, m, n) {
return (() => {
var min, max;min = n === undefined ? (() => {
return 0;
})() : (() => {
return m;
})();max = n === undefined ? (() => {
return m;
})() : (() => {
return n;
})();return Math.floor(dotDotCalc_573300145710716007(_main.dotDot_573300145710716007, Math, "randomNumber", [min, max]));
})();
};exports.approxEquals = approxEquals;
exports.approxGreaterThan = approxGreaterThan;
exports.approxLessThan = approxLessThan;
exports.radiansToDegrees = radiansToDegrees;
exports.degreesToRadians = degreesToRadians;
exports.principalRadians = principalRadians;
exports.principalDegrees = principalDegrees;
exports.roundDecimal = roundDecimal;
exports.randomNumber = randomNumber;
exports.randomInt = randomInt;