mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-02-09 09:30:06 +00:00
knip: YOLO pass, all the unused exports enabled, YAGNI for the rest (#5313)
* knip: Enable unusedBinaries, add two exceptions * knip: YOLO pass, all the unused exports enabled. Paired with @christian-byrne to allow for some special cases to remain with custom knip ignore tags. * knip: remove post-rebase
This commit is contained in:
@@ -33,10 +33,6 @@ export function appendJsonExt(path: string) {
|
||||
return path
|
||||
}
|
||||
|
||||
export function trimJsonExt(path?: string) {
|
||||
return path?.replace(/\.json$/, '')
|
||||
}
|
||||
|
||||
export function highlightQuery(text: string, query: string) {
|
||||
if (!query) return text
|
||||
|
||||
@@ -80,28 +76,6 @@ export function formatSize(value?: number) {
|
||||
return `${parseFloat((bytes / Math.pow(k, i)).toFixed(2))} ${sizes[i]}`
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds the common directory prefix between two paths
|
||||
* @example
|
||||
* findCommonPrefix('a/b/c', 'a/b/d') // returns 'a/b'
|
||||
* findCommonPrefix('x/y/z', 'a/b/c') // returns ''
|
||||
* findCommonPrefix('a/b/c', 'a/b/c/d') // returns 'a/b/c'
|
||||
*/
|
||||
export function findCommonPrefix(path1: string, path2: string): string {
|
||||
const parts1 = path1.split('/')
|
||||
const parts2 = path2.split('/')
|
||||
|
||||
const commonParts: string[] = []
|
||||
for (let i = 0; i < Math.min(parts1.length, parts2.length); i++) {
|
||||
if (parts1[i] === parts2[i]) {
|
||||
commonParts.push(parts1[i])
|
||||
} else {
|
||||
break
|
||||
}
|
||||
}
|
||||
return commonParts.join('/')
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns various filename components.
|
||||
* Example:
|
||||
@@ -423,26 +397,6 @@ export function compareVersions(
|
||||
return 0
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a currency amount to Metronome's integer representation.
|
||||
* For USD, converts to cents (multiplied by 100).
|
||||
* For all other currencies (including custom pricing units), returns the amount as is.
|
||||
* This is specific to Metronome's API requirements.
|
||||
*
|
||||
* @param amount - The amount in currency to convert
|
||||
* @param currency - The currency to convert
|
||||
* @returns The amount in Metronome's integer format (cents for USD, base units for others)
|
||||
* @example
|
||||
* toMetronomeCurrency(1.23, 'usd') // returns 123 (cents)
|
||||
* toMetronomeCurrency(1000, 'jpy') // returns 1000 (yen)
|
||||
*/
|
||||
export function toMetronomeCurrency(amount: number, currency: string): number {
|
||||
if (currency === 'usd') {
|
||||
return Math.round(amount * 100)
|
||||
}
|
||||
return amount
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts Metronome's integer amount back to a formatted currency string.
|
||||
* For USD, converts from cents to dollars.
|
||||
|
||||
@@ -15,7 +15,6 @@ import {
|
||||
isFloatInputSpec,
|
||||
isIntInputSpec
|
||||
} from '@/schemas/nodeDefSchema'
|
||||
import type { ComfyNodeDefImpl } from '@/stores/nodeDefStore'
|
||||
|
||||
import { lcm } from './mathUtil'
|
||||
|
||||
@@ -139,11 +138,3 @@ export const mergeInputSpec = (
|
||||
|
||||
return mergeCommonInputSpec(spec1, spec2)
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a node definition represents a subgraph node.
|
||||
* Subgraph nodes are created with category='subgraph' and python_module='nodes'.
|
||||
*/
|
||||
export const isSubgraphNode = (nodeDef: ComfyNodeDefImpl): boolean => {
|
||||
return nodeDef.category === 'subgraph' && nodeDef.python_module === 'nodes'
|
||||
}
|
||||
|
||||
@@ -29,34 +29,6 @@ export function satisfiesVersion(version: string, range: string): boolean {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Compares two versions and returns the difference type
|
||||
* @param version1 First version
|
||||
* @param version2 Second version
|
||||
* @returns Difference type or null if comparison fails
|
||||
*/
|
||||
export function getVersionDifference(
|
||||
version1: string,
|
||||
version2: string
|
||||
): semver.ReleaseType | null {
|
||||
try {
|
||||
const clean1 = cleanVersion(version1)
|
||||
const clean2 = cleanVersion(version2)
|
||||
return semver.diff(clean1, clean2)
|
||||
} catch {
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a version is valid according to semver
|
||||
* @param version Version string to validate
|
||||
* @returns true if version is valid
|
||||
*/
|
||||
export function isValidVersion(version: string): boolean {
|
||||
return semver.valid(version) !== null
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks version compatibility and returns conflict details.
|
||||
* Supports all semver ranges including >=, <=, >, <, ~, ^ operators.
|
||||
|
||||
Reference in New Issue
Block a user