@std/math
Обзор
Математические функции, такие как вычисление остатка от деления и ограничение диапазона значений.
import { clamp, modulo } from "@std/math";
import { assertEquals } from "@std/assert";
for (let n = -3; n <= 3; ++n) {
const val = n * 12 + 5;
// 5 o'clock is always 5 o'clock, no matter how many twelve-hour cycles you add or remove
assertEquals(modulo(val, 12), 5);
assertEquals(clamp(val, 0, 11), n === 0 ? 5 : n > 0 ? 11 : 0);
}
Добавление в проект
›_
deno add jsr:@std/math
© 2018–2025 the Deno authors
Licensed under the MIT License.
https://docs.deno.com/runtime/reference/std/math