Skip to content

Node module to convert bytes to human-readable format and reverse

License

Notifications You must be signed in to change notification settings

ashantyk/node-size

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

node-size

Convert byte/bit numbers to human-readable format and reverse. This modules supports both IEC and SI/JEDEC formats (1000 and 1024 divisions).

Installation

In order to install it you can run:

$ npm install node-size --save

Usage

Simple usage:

const size = require('node-size');

let input = 10362;
let output = size.humanReadable(input);
console.log(output); // prints '10.12 kB'

IEC standard usage:

const size = require('node-size');

let input = 10120;
let output = size.humanReadable(input, size.FORMAT.IEC);
console.log(output); // prints '10.12 KiB'

Changing default format:

const size = require('node-size');

size.setDefaultFormat(size.FORMAT.IEC);

let input = 10120;
let output = size.humanReadable(input);
console.log(output); // prints '10.12 KiB'

Machine-readable usage:

const size = require('node-size');

let input = "1 MiB";
let output = size.machineReadable(input, size.FORMAT.IEC);
console.log(output); // prints '10000000' (number)

About

Node module to convert bytes to human-readable format and reverse

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published