Skip to main content
Glama
FormatBytes.ts477 B
// 最简化展示镜像名称及tag const FormatBytes = (input: number) => { if (typeof input !== "number" || isNaN(input)) return String(input); // 统一转换为字符串 if (input === 0) return "0 B"; const sizes = ["B", "KB", "MB", "GB", "TB", "PB"]; const i = Math.floor(Math.log(input) / Math.log(1024)); const value = (input / Math.pow(1024, i)).toFixed(2); // 保留两位小数 return `${value} ${sizes[i]}`; } export default FormatBytes;

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/weibaohui/k8m'

If you have feedback or need assistance with the MCP directory API, please join our Discord server