mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-02-28 02:34:10 +00:00
[Refactor] Add util to merge input spec (#2834)
This commit is contained in:
21
src/utils/mathUtil.ts
Normal file
21
src/utils/mathUtil.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
/**
|
||||
* Finds the greatest common divisor (GCD) for two numbers.
|
||||
*
|
||||
* @param a - The first number.
|
||||
* @param b - The second number.
|
||||
* @returns The GCD of the two numbers.
|
||||
*/
|
||||
export const gcd = (a: number, b: number): number => {
|
||||
return b === 0 ? a : gcd(b, a % b)
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds the least common multiple (LCM) for two numbers.
|
||||
*
|
||||
* @param a - The first number.
|
||||
* @param b - The second number.
|
||||
* @returns The LCM of the two numbers.
|
||||
*/
|
||||
export const lcm = (a: number, b: number): number => {
|
||||
return Math.abs(a * b) / gcd(a, b)
|
||||
}
|
||||
Reference in New Issue
Block a user