A lightweight Node.js utility for working with files.
FileChecker helps developers check, analyze and validate files in their applications.
It provides simple tools for file inspection, making file handling easier for websites, APIs, cloud storage systems and backend applications.
Applications often work with many types of files:
- images;
- videos;
- documents;
- archives;
- backups.
Before using a file, a system may need to know:
- Does the file exist?
- What is its size?
- What type of file is it?
- Is the file allowed?
- Has the file changed?
FileChecker provides these checks in one simple utility.
- Check file existence
- Get file size
- Format file size
- Detect extensions
- Validate file types
- Detect empty files
- Get file information
- Generate SHA-256 hashes
const FileChecker = require("./file-checker");
console.log(FileChecker.exists("image.png"));
console.log(
FileChecker.formatSize("video.mp4")
);
console.log(
FileChecker.info("document.pdf")
);
Functions
exists()
Checks whether a file exists.
FileChecker.exists("file.txt");
---
size()
Returns file size in bytes.
FileChecker.size("file.txt");
---
formatSize()
Converts bytes into readable format.
FileChecker.formatSize("video.mp4");
Example:
25.50 MB
---
extension()
Returns file extension.
FileChecker.extension("photo.jpg");
Result:
.jpg
---
allowed()
Checks allowed file extensions.
FileChecker.allowed(
"photo.png",
[".png", ".jpg"]
);
---
info()
Returns file information.
FileChecker.info("file.pdf");
---
hash()
Creates SHA-256 file hash.
FileChecker.hash("archive.zip");
Use Cases
FileChecker can be used in:
File upload systems
Cloud storage
Backend APIs
Content management systems
File managers
Admin panels
Security
FileChecker provides basic file validation.
It does not replace:
antivirus systems;
malware detection;
access control;
server protection.
Additional security measures are recommended for production applications.
License
MIT License
You are free to use, modify and distribute this project while keeping the original license.