From bce557cc2dc767628bed6aac87301a1be7c5431b Mon Sep 17 00:00:00 2001 From: rxliuli Date: Tue, 4 Nov 2025 05:03:50 +0800 Subject: init commit --- .../app-store/tmp/src/foundation/util/math-util.js | 32 ++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 node_modules/@jet-app/app-store/tmp/src/foundation/util/math-util.js (limited to 'node_modules/@jet-app/app-store/tmp/src/foundation/util/math-util.js') diff --git a/node_modules/@jet-app/app-store/tmp/src/foundation/util/math-util.js b/node_modules/@jet-app/app-store/tmp/src/foundation/util/math-util.js new file mode 100644 index 0000000..92b4992 --- /dev/null +++ b/node_modules/@jet-app/app-store/tmp/src/foundation/util/math-util.js @@ -0,0 +1,32 @@ +/** + * Given an integer m > 1, called a modulus, two integers are said to be congruent modulo m, + * if m is a divisor of their difference (i.e., if there is an integer k such that a \u2212 b = km). + * + * Unlike JavaScript's remainder operator (%), this mod function never returns negative values. + * + * @param n An integer + * @param m The modulous + */ +export function mod(n, m) { + return ((n % m) + m) % m; +} +/** + * Reduce sig fig of `value` to `significantDigits`. + * @param value Value to reduce precision of. + * @param significantDigits Significant digits to keep. + */ +export function reduceSignificantDigits(value, significantDigits) { + const roundFactor = Math.pow(10.0, significantDigits); + const roundingFunction = value > 0.0 ? Math.floor : Math.ceil; + return roundingFunction(value / roundFactor) * roundFactor; +} +/** + * Clamps a value between an upper and lower bound. + * @param value The preferred value. + * @param min The minimum allowed value. + * @param max The maximum allowed value. + */ +export function clamp(value, min, max) { + return Math.max(min, Math.min(max, value)); +} +//# sourceMappingURL=math-util.js.map \ No newline at end of file -- cgit v1.2.3