Skip to main content
Home

@std/math@0.0.0
Built and signed on GitHub Actions

Basic math utilities

This package works with Cloudflare Workers, Node.js, Deno, Bun, Browsers
This package works with Cloudflare Workers
This package works with Node.js
This package works with Deno
This package works with Bun
This package works with Browsers
JSR Score
100%
Published
a month ago (0.0.0)

Math functions such as modulo and clamp.

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);
}
Built and signed on
GitHub Actions

New Ticket: Report package

Please provide a reason for reporting this package. We will review your report and take appropriate action.

Please review the JSR usage policy before submitting a report.

Add Package

deno add jsr:@std/math

Import symbol

import * as math from "@std/math";
or

Import directly with a jsr specifier

import * as math from "jsr:@std/math";

Add Package

pnpm i jsr:@std/math
or (using pnpm 10.8 or older)
pnpm dlx jsr add @std/math

Import symbol

import * as math from "@std/math";

Add Package

yarn add jsr:@std/math
or (using Yarn 4.8 or older)
yarn dlx jsr add @std/math

Import symbol

import * as math from "@std/math";

Add Package

vlt install jsr:@std/math

Import symbol

import * as math from "@std/math";

Add Package

npx jsr add @std/math

Import symbol

import * as math from "@std/math";

Add Package

bunx jsr add @std/math

Import symbol

import * as math from "@std/math";