master @ 16 LINES
[ HISTORY ] [ UP ]
┌─ TS ───────────────────────────────────────────────────────────────────────┐
│ export interface Props { │
│ /** 0-100. */ │
│ value: number; │
│ /** Bar width in cells, excluding brackets and the percentage. */ │
│ cells?: number; │
│ } │
│ │
│ export function buildProgress(value: number, cells = 20): string { │
│ const v = Math.max(0, Math.min(100, Math.round(value))); │
│ const filled = Math.round((v / 100) * cells); │
│ return `[${"█".repeat(filled)}${"░".repeat(cells - filled)}] ${String(v).padStar │
│ t(3)}%`; │
│ } │
│ │
│ // "[" + cells + "] 100%" │
│ export const progressWidth = (cells = 20) => cells + 7; │
└────────────────────────────────────────────────────────────────────────────────────┘
┌─ TS ─────────────────────────────────┐
│ export interface Props { │
│ /** 0-100. */ │
│ value: number; │
│ /** Bar width in cells, excluding brackets │
│ and the percentage. */ │
│ cells?: number; │
│ } │
│ │
│ export function buildProgress(value: number, │
│ cells = 20): string { │
│ const v = Math.max(0, Math.min(100, Math.r │
│ ound(value))); │
│ const filled = Math.round((v / 100) * cell │
│ s); │
│ return `[${"█".repeat(filled)}${"░".repeat │
│ (cells - filled)}] ${String(v).padStart(3)}% │
│ `; │
│ } │
│ │
│ // "[" + cells + "] 100%" │
│ export const progressWidth = (cells = 20) => │
│ cells + 7; │
└──────────────────────────────────────────────┘
──────────────────────────────────────────────────────────────────────────────────────
OOKNET
────────────────────────────────────────────────
OOKNET