UNPKG

@ant-design/x

Version:

Craft AI-driven interfaces effortlessly

20 lines (19 loc) 513 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getSize = getSize; exports.matchExt = matchExt; function getSize(size) { let retSize = size; const units = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB']; let unitIndex = 0; while (retSize >= 1024 && unitIndex < units.length - 1) { retSize /= 1024; unitIndex++; } return `${retSize.toFixed(0)} ${units[unitIndex]}`; } function matchExt(suffix, ext) { return ext.some(e => suffix.toLowerCase() === `.${e}`); }