size-converter

1.0.1 • Public • Published

size-converter

Simply convert a file size from an unit to another unit.

Usage

Install it with npm install size-converter, then use it in your project like this:

const { convertFileSize } = require('size-converter');

console.log(convertFileSize('2kb', 'bytes'));
// { "number": 2048, "string": "2048Bytes" }

IMPORTANT: In this tool, all the units in the parameter will be regard as "Byte", "Bit" is not be supported.

Reference

convertFileSize

convertFileSize: (fileSize: string, toUnit: string, unitBase?: number): ConvertSize

The default unitBase is 1024, you can set it to 1000 or sth else.

ConvertSize

Including properties named number and string, number is the file size in toUnit without the unit itself, just a number.

The string is a human-readable file size string in toUnit.

License

MIT

Readme

Keywords

none

Package Sidebar

Install

npm i size-converter

Weekly Downloads

17

Version

1.0.1

License

MIT

Unpacked Size

14 kB

Total Files

7

Last publish

Collaborators

  • backrunner