semantic update
This commit is contained in:
@@ -19,10 +19,23 @@
|
||||
export let files = [];
|
||||
const dispatch = createEventDispatcher();
|
||||
|
||||
// [DEF:isDirectory:Function]
|
||||
/**
|
||||
* @purpose Checks if a file object represents a directory.
|
||||
* @param {Object} file - The file object to check.
|
||||
* @return {boolean} True if it's a directory, false otherwise.
|
||||
*/
|
||||
function isDirectory(file) {
|
||||
return file.mime_type === 'directory';
|
||||
}
|
||||
// [/DEF:isDirectory:Function]
|
||||
|
||||
// [DEF:formatSize:Function]
|
||||
/**
|
||||
* @purpose Formats file size in bytes into a human-readable string.
|
||||
* @param {number} bytes - The size in bytes.
|
||||
* @return {string} Formatted size (e.g., "1.2 MB").
|
||||
*/
|
||||
function formatSize(bytes) {
|
||||
if (bytes === 0) return '0 B';
|
||||
const k = 1024;
|
||||
@@ -30,10 +43,18 @@
|
||||
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
||||
return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + ' ' + sizes[i];
|
||||
}
|
||||
// [/DEF:formatSize:Function]
|
||||
|
||||
// [DEF:formatDate:Function]
|
||||
/**
|
||||
* @purpose Formats an ISO date string into a localized readable format.
|
||||
* @param {string} dateStr - The date string to format.
|
||||
* @return {string} Localized date and time.
|
||||
*/
|
||||
function formatDate(dateStr) {
|
||||
return new Date(dateStr).toLocaleString();
|
||||
}
|
||||
// [/DEF:formatDate:Function]
|
||||
</script>
|
||||
|
||||
<!-- [SECTION: TEMPLATE] -->
|
||||
|
||||
Reference in New Issue
Block a user