Some checks failed
Python Linting / Run Ruff (push) Has been cancelled
Python Linting / Run Pylint (push) Has been cancelled
Full Comfy CI Workflow Runs / test-stable (12.1, , linux, 3.10, [self-hosted Linux], stable) (push) Has been cancelled
Full Comfy CI Workflow Runs / test-stable (12.1, , linux, 3.11, [self-hosted Linux], stable) (push) Has been cancelled
Full Comfy CI Workflow Runs / test-stable (12.1, , linux, 3.12, [self-hosted Linux], stable) (push) Has been cancelled
Full Comfy CI Workflow Runs / test-unix-nightly (12.1, , linux, 3.11, [self-hosted Linux], nightly) (push) Has been cancelled
Execution Tests / test (macos-latest) (push) Has been cancelled
Execution Tests / test (ubuntu-latest) (push) Has been cancelled
Execution Tests / test (windows-latest) (push) Has been cancelled
Test server launches without errors / test (push) Has been cancelled
Unit Tests / test (macos-latest) (push) Has been cancelled
Unit Tests / test (ubuntu-latest) (push) Has been cancelled
Unit Tests / test (windows-2022) (push) Has been cancelled
Includes 30 custom nodes committed directly, 7 Civitai-exclusive loras stored via Git LFS, and a setup script that installs all dependencies and downloads HuggingFace-hosted models on vast.ai. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
65 lines
1.9 KiB
TypeScript
65 lines
1.9 KiB
TypeScript
export function numberToWords(num: number): string {
|
|
if (num === 0) return 'zero';
|
|
|
|
const belowTwenty = [
|
|
'', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten',
|
|
'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen'
|
|
];
|
|
const tens = ['', '', 'twenty', 'thirty', 'forty', 'fifty', 'sixty', 'seventy', 'eighty', 'ninety'];
|
|
const thousands = ['', 'thousand', 'million', 'billion'];
|
|
|
|
function helper(n: number): string {
|
|
if (n === 0) return '';
|
|
else if (n < 20) return belowTwenty[n] + ' ';
|
|
else if (n < 100) return tens[Math.floor(n / 10)] + ' ' + helper(n % 10);
|
|
return belowTwenty[Math.floor(n / 100)] + ' hundred ' + helper(n % 100);
|
|
}
|
|
|
|
let word = '';
|
|
let i = 0;
|
|
|
|
while (num > 0) {
|
|
if (num % 1000 !== 0) {
|
|
word = helper(num % 1000) + thousands[i] + ' ' + word;
|
|
}
|
|
num = Math.floor(num / 1000);
|
|
i++;
|
|
}
|
|
|
|
return word.trim();
|
|
}
|
|
|
|
export function toPascalCase(strings: string[]): string {
|
|
if (!Array.isArray(strings)) return '';
|
|
|
|
function capitalize(word: string): string {
|
|
return word.charAt(0).toUpperCase() + word.slice(1).toLowerCase();
|
|
}
|
|
|
|
return strings.map(capitalize).join('');
|
|
}
|
|
|
|
|
|
export function convertNumberToPascalCase(num: number): string {
|
|
return toPascalCase(numberToWords(num).split(' '));
|
|
}
|
|
|
|
export function formatBytes(bytes: number): string {
|
|
if (bytes === 0) return '0 Bytes';
|
|
|
|
const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB'];
|
|
const i = Math.floor(Math.log(bytes) / Math.log(1024));
|
|
const formattedSize = (bytes / Math.pow(1024, i)).toFixed(2);
|
|
|
|
return `${formattedSize} ${sizes[i]}`;
|
|
}
|
|
|
|
export function createStyleSheet(id: string): HTMLStyleElement {
|
|
const style = document.createElement('style');
|
|
style.setAttribute('id', id);
|
|
style.setAttribute('rel', 'stylesheet');
|
|
style.setAttribute('type', 'text/css');
|
|
document.head.appendChild(style);
|
|
return style;
|
|
}
|