1.0.1 • Published 4 months ago

filesizeformatter v1.0.1

Weekly downloads
-
License
ISC
Repository
github
Last release
4 months ago

filesizeformatter

npm version

Description

filesizeformatter is a lightweight and simple-to-use Node.js package to format file sizes. It provides a function to convert file sizes from bytes to human-readable units like kilobytes, megabytes, gigabytes, etc.

Installation

npm install filesizeformatter

Usage

const { fileSizeFormat } = require('filesizeformatter');

const exampleSize: number = 2048;
fileSizeFormat(exampleSize, false).then(result => {
  console.log(result);
});

Options

size: The file size in bytes. useBinaryUnits: (Optional) If set to true, uses binary units (e.g., KiB, MiB) instead of decimal units (e.g., KB, MB). Default is false.

Example

const { fileSizeFormat } = require('filesizeformatter');

const fileSize = 1024;
const exampleSize: number = 2048;
fileSizeFormat(exampleSize, false).then(result => {
  console.log(result);
});
// Output: "2.00 KB"

Contributing

Contributions to filesizeformatter are welcome! If you'd like to contribute to this project, please follow these steps: 1. Fork the repository. 2. Create a new branch for your feature or bug fix: git checkout -b feature/your-feature-name. 3. Commit your changes: git commit -m "Add your feature or fix". 4. Push your branch to your fork: git push origin feature/your-feature-name. 5. Create a pull request on the original repository.

Please follow the Code of Conduct and Contributing Guidelines when contributing.

Buy Me A Coffee

1.0.1

4 months ago

1.0.0

4 months ago