enh: show extracted file content
This commit is contained in:
@@ -873,3 +873,21 @@ export const createMessagesList = (history, messageId) => {
|
||||
return [message];
|
||||
}
|
||||
};
|
||||
|
||||
export const formatFileSize = (size) => {
|
||||
if (size == null) return 'Unknown size';
|
||||
if (typeof size !== 'number' || size < 0) return 'Invalid size';
|
||||
if (size === 0) return '0 B';
|
||||
const units = ['B', 'KB', 'MB', 'GB', 'TB'];
|
||||
let unitIndex = 0;
|
||||
|
||||
while (size >= 1024 && unitIndex < units.length - 1) {
|
||||
size /= 1024;
|
||||
unitIndex++;
|
||||
}
|
||||
return `${size.toFixed(1)} ${units[unitIndex]}`;
|
||||
};
|
||||
|
||||
export const getLineCount = (text) => {
|
||||
return text.split('\n').length;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user