File & Byte Utilities
File size formatting, extension extraction, and MIME type helpers in sc-fns/file.
The sc-fns/file module provides helpers for parsing file paths, extensions, formatting byte counts, and media type detection.
ts
formatFileSize
Converts a byte count into a human-readable size string (B, KB, MB, GB, TB, PB).
Signature
ts
Examples
ts
getFileExtension
Extracts the lowercase file extension from a filename or path without the leading dot.
Signature
ts
Examples
ts
getFileName
Extracts the basename from a file path, with an option to include or exclude the extension.
Signature
ts
Examples
ts
Media Guards: isImage, isVideo, isPDF
Tests if a filename, extension, or MIME type represents an image, video, or PDF document.
Examples
ts
How is this guide?
Last updated on October 25, 2026