
Security News
AGENTS.md Gains Traction as an Open Format for AI Coding Agents
AGENTS.md is a fast-growing open format giving AI coding agents a shared, predictable way to understand project setup, style, and workflows.
A utility to check the size of files or folders and convert sizes between different units.
ByteSizes is a lightweight and powerful Node.js package for checking the size of files or folders with the ability to easily convert between different units. It's designed to help developers manage and monitor filesystem sizes with a simple, intuitive interface and efficient error handling.
Install ByteSizes using npm:
npm install bytesizes
Here's a simple example demonstrating how to use ByteSizes:
const ByteSizes = require('bytesizes');
(async () => {
try {
// Get file size and convert it to KB
const fileSize = await ByteSizes.getFileSize('example.txt');
console.log(`File Size: ${ByteSizes.convertSize(fileSize, 'KB')}`);
// Get folder size and convert it to MB
const folderSize = await ByteSizes.getFolderSize('myFolder');
console.log(`Folder Size: ${ByteSizes.convertSize(folderSize, 'MB')}`);
} catch (error) {
console.error('Error:', error.message);
}
})();
If you're using TypeScript or ES Modules (.mjs
), you can import the module as follows:
import ByteSizes from 'bytesizes';
// Same usage as above
getFileSize(filePath: string): Promise<number>
filePath
: The path to the file.getFolderSize(folderPath: string): Promise<number>
folderPath
: The path to the folder.convertSize(sizeInBytes: number, unit: string): string
sizeInBytes
: The size in bytes to convert.unit
: The unit to convert to (bytes
, KB
, MB
, GB
, TB
, PB
, EB
).ByteSizes ensures clear and descriptive error messages for easier troubleshooting. When an error occurs, the stack trace is provided for better context.
Example:
✖ ERROR: Error reading file or directory: example.txt
└─ Stack Trace:
Error: ENOENT: no such file or directory, open 'D:\Path\To\example.txt'
This project is licensed under the MIT License. See the LICENSE file for more details.
Contributions are welcome! If you'd like to contribute, please open an issue or submit a pull request on GitHub. All contributions must follow coding best practices and include relevant test cases.
FAQs
A utility to check the size of files or folders and convert sizes between different units.
The npm package bytesizes receives a total of 4 weekly downloads. As such, bytesizes popularity was classified as not popular.
We found that bytesizes demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
AGENTS.md is a fast-growing open format giving AI coding agents a shared, predictable way to understand project setup, style, and workflows.
Security News
/Research
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
Security News
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.