@thi.ng/math
Advanced tools
Comparing version 5.10.12 to 5.10.13
# Change Log | ||
- **Last updated**: 2024-04-23T07:02:18Z | ||
- **Last updated**: 2024-05-08T18:24:32Z | ||
- **Generator**: [thi.ng/monopub](https://thi.ng/monopub) | ||
@@ -5,0 +5,0 @@ |
@@ -17,4 +17,3 @@ const isMinima = (a, b, c) => a > b && b < c; | ||
const i = fn(vals, from, to); | ||
if (i < 0) | ||
return; | ||
if (i < 0) return; | ||
yield i; | ||
@@ -21,0 +20,0 @@ from = i + 1; |
@@ -8,14 +8,11 @@ const clamp = (x, min, max) => x < min ? min : x > max ? max : x; | ||
const wrap = (x, min, max) => { | ||
if (min === max) | ||
return min; | ||
if (min === max) return min; | ||
if (x > max) { | ||
const d = max - min; | ||
x -= d; | ||
if (x > max) | ||
x -= d * ((x - min) / d | 0); | ||
if (x > max) x -= d * ((x - min) / d | 0); | ||
} else if (x < min) { | ||
const d = max - min; | ||
x += d; | ||
if (x < min) | ||
x += d * ((min - x) / d + 1 | 0); | ||
if (x < min) x += d * ((min - x) / d + 1 | 0); | ||
} | ||
@@ -22,0 +19,0 @@ return x; |
@@ -7,4 +7,3 @@ const copysign = (x, y) => Math.sign(y) * Math.abs(x); | ||
const frexp = (x) => { | ||
if (x === 0 || !isFinite(x)) | ||
return [x, 0]; | ||
if (x === 0 || !isFinite(x)) return [x, 0]; | ||
const abs = Math.abs(x); | ||
@@ -11,0 +10,0 @@ let exp = Math.max(-1023, Math.floor(Math.log2(abs)) + 1); |
import { EPS } from "./api.js"; | ||
const minError = (fn, error, q, res = 16, iter = 8, start = 0, end = 1, eps = EPS) => { | ||
if (iter <= 0) | ||
return (start + end) / 2; | ||
if (iter <= 0) return (start + end) / 2; | ||
const delta = (end - start) / res; | ||
@@ -12,4 +11,3 @@ let minT = start; | ||
if (e < minE) { | ||
if (e <= eps) | ||
return t; | ||
if (e <= eps) return t; | ||
minE = e; | ||
@@ -16,0 +14,0 @@ minT = t; |
{ | ||
"name": "@thi.ng/math", | ||
"version": "5.10.12", | ||
"version": "5.10.13", | ||
"description": "Assorted common math functions & utilities", | ||
@@ -42,9 +42,9 @@ "type": "module", | ||
"dependencies": { | ||
"@thi.ng/api": "^8.11.1" | ||
"@thi.ng/api": "^8.11.2" | ||
}, | ||
"devDependencies": { | ||
"@microsoft/api-extractor": "^7.43.0", | ||
"esbuild": "^0.20.2", | ||
"typedoc": "^0.25.12", | ||
"typescript": "^5.4.3" | ||
"@microsoft/api-extractor": "^7.43.2", | ||
"esbuild": "^0.21.1", | ||
"typedoc": "^0.25.13", | ||
"typescript": "^5.4.5" | ||
}, | ||
@@ -146,3 +146,3 @@ "keywords": [ | ||
}, | ||
"gitHead": "5dd66c18a3862a3af69a5b2f49563f7cbdd960c2\n" | ||
"gitHead": "df34b4a9e650cc7323575356de207d78933bdcf3\n" | ||
} |
const factorial = (n) => { | ||
if (n < 0) | ||
throw new Error(`illegal argument: ${n}`); | ||
if (n < 0) throw new Error(`illegal argument: ${n}`); | ||
let res = 1; | ||
for (let i = 1; i <= n; i++) | ||
res *= i; | ||
for (let i = 1; i <= n; i++) res *= i; | ||
return res; | ||
@@ -8,0 +6,0 @@ }; |
function* primesUntil(x) { | ||
if (x < 1) | ||
return; | ||
if (x < 1) return; | ||
yield 1; | ||
@@ -15,4 +14,3 @@ const sieve = []; | ||
const nearestPrime = (x) => { | ||
if (x < 1) | ||
return -1; | ||
if (x < 1) return -1; | ||
let prime = 1; | ||
@@ -31,4 +29,3 @@ const sieve = []; | ||
if (i <= max) { | ||
for (let j = i * i; j <= x; j += i) | ||
sieve[j] = true; | ||
for (let j = i * i; j <= x; j += i) sieve[j] = true; | ||
} | ||
@@ -35,0 +32,0 @@ }; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
97675
2190
Updated@thi.ng/api@^8.11.2