Compare commits

...

1 Commits

Author SHA1 Message Date
bymyself
5c93dfaf81 chore: remove unused gcd() export from mathUtil.ts
Remove the public export of gcd() — no production consumer exists.
The function is retained as a private helper for lcm() which is
used by nodeDefUtil.ts. Corresponding gcd tests are removed.

Fixes #11082
2026-04-10 08:42:07 +00:00
2 changed files with 1 additions and 25 deletions

View File

@@ -4,7 +4,6 @@ import type { ReadOnlyRect } from '@/lib/litegraph/src/interfaces'
import {
computeUnionBounds,
denormalize,
gcd,
lcm,
normalize
} from '@/utils/mathUtil'
@@ -34,29 +33,6 @@ describe('mathUtil', () => {
})
})
describe('gcd', () => {
it('should compute greatest common divisor correctly', () => {
expect(gcd(48, 18)).toBe(6)
expect(gcd(100, 25)).toBe(25)
expect(gcd(17, 13)).toBe(1)
expect(gcd(0, 5)).toBe(5)
expect(gcd(5, 0)).toBe(5)
})
it('should handle negative numbers', () => {
expect(gcd(-48, 18)).toBe(6)
expect(gcd(48, -18)).toBe(6)
expect(gcd(-48, -18)).toBe(6)
})
it('should not cause stack overflow with small floating-point step values', () => {
// This would cause Maximum call stack size exceeded with recursive impl
// when used in lcm calculations with small step values
expect(() => gcd(0.0001, 0.0003)).not.toThrow()
expect(() => gcd(1e-10, 1e-9)).not.toThrow()
})
})
describe('lcm', () => {
it('should compute least common multiple correctly', () => {
expect(lcm(4, 6)).toBe(12)

View File

@@ -35,7 +35,7 @@ type Vec2 = readonly [number, number]
* @param b - The second number.
* @returns The GCD of the two numbers.
*/
export const gcd = (a: number, b: number): number => {
const gcd = (a: number, b: number): number => {
// Use absolute values to handle negative numbers
let x = Math.abs(a)
let y = Math.abs(b)