Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
86 commits
Select commit Hold shift + click to select a range
082a9d4
docs(deno.lock): improve doc comments in deno.lock
nberlette Jan 24, 2026
0617f03
docs(abs): improve doc comments in abs.ts
nberlette Jan 24, 2026
da60331
docs(acos): improve doc comments in acos.ts
nberlette Jan 24, 2026
ef8b42e
docs(acosh): improve doc comments in acosh.ts
nberlette Jan 24, 2026
cb3c85d
docs(asin): improve doc comments in asin.ts
nberlette Jan 24, 2026
fad3ebd
docs(asinh): improve doc comments in asinh.ts
nberlette Jan 24, 2026
4d2ef66
docs(atan): improve doc comments in atan.ts
nberlette Jan 24, 2026
85fb05b
docs(atan2): improve doc comments in atan2.ts
nberlette Jan 24, 2026
0ded160
docs(atanh): improve doc comments in atanh.ts
nberlette Jan 24, 2026
c95283e
docs(cbrt): improve doc comments in cbrt.ts
nberlette Jan 24, 2026
fb8ff3a
docs(ceil): improve doc comments in ceil.ts
nberlette Jan 24, 2026
b3780ca
docs(clamp): improve doc comments in clamp.ts
nberlette Jan 24, 2026
7f7402b
docs(clz32): improve doc comments in clz32.ts
nberlette Jan 24, 2026
6c1d4d3
docs(constants): improve doc comments in constants/e.ts
nberlette Jan 24, 2026
65252a9
docs(constants): improve doc comments in constants/epsilon.ts
nberlette Jan 24, 2026
c29258d
docs(constants): improve doc comments in constants/index.ts
nberlette Jan 24, 2026
a0f4fd7
docs(constants): improve doc comments in constants/infinity.ts
nberlette Jan 24, 2026
55a331f
docs(constants): improve doc comments in constants/ln10.ts
nberlette Jan 24, 2026
3280277
docs(constants): improve doc comments in constants/ln2.ts
nberlette Jan 24, 2026
ff09ec2
docs(constants): improve doc comments in constants/log10e.ts
nberlette Jan 24, 2026
614b309
docs(constants): improve doc comments in constants/log2e.ts
nberlette Jan 24, 2026
04d0328
docs(constants): improve doc comments in constants/max_safe_integer.ts
nberlette Jan 24, 2026
b41a74d
docs(constants): improve doc comments in constants/max_value.ts
nberlette Jan 24, 2026
17f799b
docs(constants): improve doc comments in constants/min_safe_integer.ts
nberlette Jan 24, 2026
b11bc2e
docs(constants): improve doc comments in constants/min_value.ts
nberlette Jan 24, 2026
fa30195
docs(constants): improve doc comments in constants/nan.ts
nberlette Jan 24, 2026
e605bbf
docs(constants): improve doc comments in constants/negative_infinity.ts
nberlette Jan 24, 2026
3496e88
docs(constants): improve doc comments in constants/pi.ts
nberlette Jan 24, 2026
c0a501c
docs(constants): improve doc comments in constants/positive_infinity.ts
nberlette Jan 24, 2026
c53d10c
docs(constants): improve doc comments in constants/positive_zero.ts
nberlette Jan 24, 2026
621153a
docs(constants): improve doc comments in constants/sqrt1_2.ts
nberlette Jan 24, 2026
f040fe5
docs(constants): improve doc comments in constants/sqrt2.ts
nberlette Jan 24, 2026
3a3ca13
docs(cos): improve doc comments in cos.ts
nberlette Jan 24, 2026
b2ee98a
docs(cosh): improve doc comments in cosh.ts
nberlette Jan 24, 2026
4c741d8
docs(exp): improve doc comments in exp.ts
nberlette Jan 24, 2026
b075a07
docs(expm1): improve doc comments in expm1.ts
nberlette Jan 24, 2026
8756648
docs(f16round): improve doc comments in f16round.ts
nberlette Jan 24, 2026
69e730d
docs(float16): improve doc comments in float16/constants.ts
nberlette Jan 24, 2026
ab6ac4a
docs(float16): improve doc comments in float16/decode.ts
nberlette Jan 24, 2026
bc19b92
docs(float16): improve doc comments in float16/encode.ts
nberlette Jan 24, 2026
77e269a
docs(float16): improve doc comments in float16/guards.ts
nberlette Jan 24, 2026
c858b54
docs(float16): improve doc comments in float16/index.ts
nberlette Jan 24, 2026
06af4c7
docs(float16): improve doc comments in float16/round.ts
nberlette Jan 24, 2026
77ce161
docs(float32): improve doc comments in float32/constants.ts
nberlette Jan 24, 2026
5edaf41
docs(float32): improve doc comments in float32/decode.ts
nberlette Jan 24, 2026
fc66ef0
docs(float32): improve doc comments in float32/encode.ts
nberlette Jan 24, 2026
7cc4424
docs(float32): improve doc comments in float32/guards.ts
nberlette Jan 24, 2026
ac262bc
docs(float32): improve doc comments in float32/index.ts
nberlette Jan 24, 2026
39b206b
docs(float32): improve doc comments in float32/round.ts
nberlette Jan 24, 2026
aa3d932
docs(floor): improve doc comments in floor.ts
nberlette Jan 24, 2026
bd22f26
docs(fround): improve doc comments in fround.ts
nberlette Jan 24, 2026
0d2bfcf
docs(guards): improve doc comments in guards/finite.ts
nberlette Jan 24, 2026
279130c
docs(guards): improve doc comments in guards/index.ts
nberlette Jan 24, 2026
a0c86f3
docs(guards): improve doc comments in guards/infinity.ts
nberlette Jan 24, 2026
5282179
docs(guards): improve doc comments in guards/integer.ts
nberlette Jan 24, 2026
263e5f7
docs(guards): improve doc comments in guards/negative_infinity.ts
nberlette Jan 24, 2026
8008ee2
docs(guards): improve doc comments in guards/negative_zero.ts
nberlette Jan 24, 2026
7fa942f
docs(guards): improve doc comments in guards/positive_infinity.ts
nberlette Jan 24, 2026
ad92c7a
docs(guards): improve doc comments in guards/positive_zero.ts
nberlette Jan 24, 2026
c79e7cf
docs(guards): improve doc comments in guards/safe_integer.ts
nberlette Jan 24, 2026
d43de1f
docs(hypot): improve doc comments in hypot.ts
nberlette Jan 24, 2026
b618a84
docs(ieee754): improve doc comments in ieee754.ts
nberlette Jan 24, 2026
ece31fe
docs(imul): improve doc comments in imul.ts
nberlette Jan 24, 2026
59e5141
docs(index): improve doc comments in index.ts
nberlette Jan 24, 2026
f807e54
docs(log): improve doc comments in log.ts
nberlette Jan 24, 2026
8ddd80c
docs(log10): improve doc comments in log10.ts
nberlette Jan 24, 2026
48730e2
docs(log1p): improve doc comments in log1p.ts
nberlette Jan 24, 2026
37d9b3b
docs(log2): improve doc comments in log2.ts
nberlette Jan 24, 2026
fc417c0
docs(max): improve doc comments in max.ts
nberlette Jan 24, 2026
01895e8
docs(min): improve doc comments in min.ts
nberlette Jan 24, 2026
5a5d234
docs(pow): improve doc comments in pow.ts
nberlette Jan 24, 2026
4041dd5
docs(random): improve doc comments in random.ts
nberlette Jan 24, 2026
a61af03
docs(round): improve doc comments in round.ts
nberlette Jan 24, 2026
93ede4c
docs(sign): improve doc comments in sign.ts
nberlette Jan 24, 2026
97c8ae5
docs(sin): improve doc comments in sin.ts
nberlette Jan 24, 2026
fafa94f
docs(sinh): improve doc comments in sinh.ts
nberlette Jan 24, 2026
eb2e8ed
docs(sqrt): improve doc comments in sqrt.ts
nberlette Jan 24, 2026
744d312
docs(tan): improve doc comments in tan.ts
nberlette Jan 24, 2026
141e869
docs(tanh): improve doc comments in tanh.ts
nberlette Jan 24, 2026
7c6b9cb
docs(trunc): improve doc comments in trunc.ts
nberlette Jan 24, 2026
c1ee350
docs(types): improve doc comments in types/finite.ts
nberlette Jan 24, 2026
a726a66
docs(types): improve doc comments in types/float.ts
nberlette Jan 24, 2026
bbfb5b5
docs(types): improve doc comments in types/index.ts
nberlette Jan 24, 2026
95c4bba
docs(types): improve doc comments in types/integer.ts
nberlette Jan 24, 2026
58cb2ab
docs(types): improve doc comments in types/precision.ts
nberlette Jan 24, 2026
c6e43d8
docs(types): improve doc comments in types/safe_integer.ts
nberlette Jan 24, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions deno.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions src/abs.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
/**
* Performant local implementation of the `Math.abs` function.
*
* @example
* ```ts
* import { abs } from "@nick/math/abs";
* import assert from "node:assert";
*
* assert.strictEqual(abs(-3.5), 3.5);
* ```
* @module abs
*/

Expand Down
7 changes: 7 additions & 0 deletions src/acos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@
* Calculates the arccosine (inverse cosine) of a number, returning a value in
* the range `[0, π]`.
*
* @example
* ```ts
* import { acos } from "@nick/math/acos";
* import assert from "node:assert";
*
* assert.strictEqual(acos(1), 0);
* ```
* @module acos
*/

Expand Down
7 changes: 7 additions & 0 deletions src/acosh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@
* the range `[0, +Infinity]`.
*
* @category Trigonometry
* @example
* ```ts
* import { acosh } from "@nick/math/acosh";
* import assert from "node:assert";
*
* assert.strictEqual(acosh(1), 0);
* ```
* @module acosh
*/
import { NAN } from "./constants/nan.ts";
Expand Down
7 changes: 7 additions & 0 deletions src/asin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@
* range `[-π/2, π/2]`.
*
* @category Trigonometry
* @example
* ```ts
* import { asin } from "@nick/math/asin";
* import assert from "node:assert";
*
* assert.strictEqual(asin(0), 0);
* ```
* @module asin
*/
import { NAN } from "./constants/nan.ts";
Expand Down
7 changes: 7 additions & 0 deletions src/asinh.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
/**
* Calculates the inverse hyperbolic sine of a number.
*
* @example
* ```ts
* import { asinh } from "@nick/math/asinh";
* import assert from "node:assert";
*
* assert.strictEqual(asinh(0), 0);
* ```
* @module asinh
*/
import { isFinite } from "./guards/finite.ts";
Expand Down
7 changes: 7 additions & 0 deletions src/atan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@
* Calculates the arctangent (inverse tangent) of a number, returning a value
* in the range `[-π/2, π/2]`.
*
* @example
* ```ts
* import { atan } from "@nick/math/atan";
* import assert from "node:assert";
*
* assert.strictEqual(atan(0), 0);
* ```
* @module atan
*/
import { abs } from "./abs.ts";
Expand Down
7 changes: 7 additions & 0 deletions src/atan2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@
* Calculates the arctangent of the quotient of its arguments, `y / x`,
* returning a value in the range `(-π, π]`.
*
* @example
* ```ts
* import { atan2 } from "@nick/math/atan2";
* import assert from "node:assert";
*
* assert.strictEqual(atan2(0, 1), 0);
* ```
* @module atan2
*/
import { NAN } from "./constants/nan.ts";
Expand Down
7 changes: 7 additions & 0 deletions src/atanh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@
* Calculates the inverse hyperbolic tangent of a number, returning a value in
* the range `[-∞, +∞]`.
*
* @example
* ```ts
* import { atanh } from "@nick/math/atanh";
* import assert from "node:assert";
*
* assert.strictEqual(atanh(0), 0);
* ```
* @module atanh
*/
import { isNaN, NAN } from "./guards/nan.ts";
Expand Down
7 changes: 7 additions & 0 deletions src/cbrt.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
/**
* Calculates the cube root of a number, handling negative values as well.
*
* @example
* ```ts
* import { cbrt } from "@nick/math/cbrt";
* import assert from "node:assert";
*
* assert.ok(Math.abs(cbrt(27) - 3) < 1e-12);
* ```
* @module cbrt
*/
import { abs } from "./abs.ts";
Expand Down
7 changes: 7 additions & 0 deletions src/ceil.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
/**
* Performant local implementation of the `Math.ceil` function.
*
* @example
* ```ts
* import { ceil } from "@nick/math/ceil";
* import assert from "node:assert";
*
* assert.strictEqual(ceil(1.2), 2);
* ```
* @module ceil
*/

Expand Down
7 changes: 7 additions & 0 deletions src/clamp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@
*
* **Note**: this is a non-standard utility function.
*
* @example
* ```ts
* import { clamp } from "@nick/math/clamp";
* import assert from "node:assert";
*
* assert.strictEqual(clamp(10, 0, 5), 5);
* ```
* @module clamp
*/
import { max } from "./max.ts";
Expand Down
7 changes: 7 additions & 0 deletions src/clz32.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@
* `Math.clz32` function, which counts the number of leading zero bits in the
* 32-bit binary representation of a number.
*
* @example
* ```ts
* import { clz32 } from "@nick/math/clz32";
* import assert from "node:assert";
*
* assert.strictEqual(clz32(1), 31);
* ```
* @module clz32
*/

Expand Down
7 changes: 7 additions & 0 deletions src/constants/e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@
* This module provides a constant value for the mathematical constant `e` on
* the runtime value-level, and also the compile-time type-only level.
*
* @example
* ```ts
* import { E } from "@nick/math/constants/e";
* import assert from "node:assert";
*
* assert.strictEqual(E, Math.E);
* ```
* @module e
*/

Expand Down
7 changes: 7 additions & 0 deletions src/constants/epsilon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@
* This is approximately equal to `2.220446049250313e-16`, and is provided as a
* local implementation of the native `Number.EPSILON` constant.
*
* @example
* ```ts
* import { EPSILON } from "@nick/math/constants/epsilon";
* import assert from "node:assert";
*
* assert.strictEqual(EPSILON, Number.EPSILON);
* ```
* @module epsilon
*/

Expand Down
9 changes: 9 additions & 0 deletions src/constants/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
/**
* This module re-exports all of the `@nick/math/constants/*` submodules.
*
* @example
* ```ts
* import { E, PI } from "@nick/math/constants";
* import assert from "node:assert";
*
* assert.strictEqual(E, Math.E);
* assert.strictEqual(PI, Math.PI);
* ```
* @category Constants
* @module constants
*/
export * from "./e.ts";
Expand Down
16 changes: 16 additions & 0 deletions src/constants/infinity.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,18 @@
/**
* Re-exports the positive and negative infinity constants and their
* matching type aliases from the constants submodules.
*
* @example
* ```ts
* import { NEGATIVE_INFINITY, POSITIVE_INFINITY } from "@nick/math/constants/infinity";
* import assert from "node:assert";
*
* assert.strictEqual(POSITIVE_INFINITY, Number.POSITIVE_INFINITY);
* assert.strictEqual(NEGATIVE_INFINITY, Number.NEGATIVE_INFINITY);
* ```
* @category Constants
* @module constants/infinity
*/

export * from "./positive_infinity.ts";
export * from "./negative_infinity.ts";
52 changes: 49 additions & 3 deletions src/constants/ln10.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,55 @@
/**
* Represents the natural logarithm of `10`, approximately equal to
* `2.302585092994046`.
* This module provides runtime and type-level implementations of the `LN10`
* constant found in the native `Math` namespace, which represents the natural
* logarithm of the number `10` (approximately equal to `2.302585092994046`).
*
* This is a local implementation of the native `Math.LN10` constant.
* The `LN10` constant exported by this module can be imported using a standard
* named import (i.e., at the _value_ level), or via a type-only import for a
* compile-time only reference to the same value.
*
* @example
* ```ts
* import { LN10 } from "@nick/math/constants/ln10";
* import assert from "node:assert";
*
* assert.strictEqual(LN10, 2.302585092994046);
* ```
* @example
* ```ts
* import type { LN10 } from "@nick/math/constants/ln10";
* import { expectType } from "jsr:@nick/is@0.2.0-rc.6/type/expect";
*
* expectType<LN10>(2.302585092994046);
* ```
* @module ln10
*/

/**
* Represents the natural logarithm of the number `10`, approximately equal to
* `2.302585092994046`. This corresponds to the native `Math.LN10` constant.
* @example
* ```ts
* import { LN10 } from "@nick/math/constants/ln10";
* import assert from "node:assert";
*
* assert.strictEqual(LN10, 2.302585092994046);
* ```
* @category Constants
*/
export const LN10: LN10 = 2.302585092994046;

/**
* Type-level alias of the `LN10` constant exported by this module. This allows
* `LN10` to be imported using a standard named import (i.e. the _value_ level)
* or via type-only import for a compile-time only reference to the same value.
*
* @example
* ```ts
* import type { LN10 } from "@nick/math/constants/ln10";
* import { expectType } from "jsr:@nick/is@0.2.0-rc.6/type/expect";
*
* expectType<LN10>(2.302585092994046);
* ```
* @category Constants
*/
export type LN10 = 2.302585092994046;
15 changes: 15 additions & 0 deletions src/constants/ln2.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
/**
* This module provides runtime and type-level implementations of the
* `LN2` constant, the natural logarithm of 2.
*
* @example
* ```ts
* import { LN2 } from "@nick/math/constants/ln2";
* import assert from "node:assert";
*
* assert.strictEqual(LN2, Math.LN2);
* ```
* @category Constants
* @module ln2
*/

/**
* Represents the natural logarithm of `2`, approximately equal to
* `0.6931471805599453`.
Expand Down
15 changes: 15 additions & 0 deletions src/constants/log10e.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
/**
* This module provides runtime and type-level implementations of the
* `LOG10E` constant, the base-10 logarithm of e.
*
* @example
* ```ts
* import { LOG10E } from "@nick/math/constants/log10e";
* import assert from "node:assert";
*
* assert.strictEqual(LOG10E, Math.LOG10E);
* ```
* @category Constants
* @module log10e
*/

/**
* Represents the base-10 logarithm of `e` (Euler's number), approximately
* equal to `0.4342944819032518`.
Expand Down
15 changes: 15 additions & 0 deletions src/constants/log2e.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
/**
* This module provides runtime and type-level implementations of the
* `LOG2E` constant, the base-2 logarithm of e.
*
* @example
* ```ts
* import { LOG2E } from "@nick/math/constants/log2e";
* import assert from "node:assert";
*
* assert.strictEqual(LOG2E, Math.LOG2E);
* ```
* @category Constants
* @module log2e
*/

/**
* Represents the base-2 logarithm of `e` (Euler's number), approximately equal
* to `1.4426950408889634`.
Expand Down
15 changes: 15 additions & 0 deletions src/constants/max_safe_integer.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
/**
* This module provides runtime and type-level implementations of the
* `MAX_SAFE_INTEGER` constant, matching `Number.MAX_SAFE_INTEGER`.
*
* @example
* ```ts
* import { MAX_SAFE_INTEGER } from "@nick/math/constants/max-safe-integer";
* import assert from "node:assert";
*
* assert.strictEqual(MAX_SAFE_INTEGER, Number.MAX_SAFE_INTEGER);
* ```
* @category Constants
* @module max-safe-integer
*/

/**
* Represents the largest integer that can be represented in JavaScript without
* losing precision, which is approximately equal to `9007199254740991`.
Expand Down
Loading
Loading