Skip to content
This repository has been archived by the owner on Sep 14, 2020. It is now read-only.
/ sizeToBytes.js Public archive

A simple function that returns the number of bytes in a human readable size.

Notifications You must be signed in to change notification settings

antonsamper/sizeToBytes.js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

sizeToBytes.js

A simple function that returns the number of bytes in a human readable size.

sizeToBytes.js by [Anton Samper Rivaya] (http://aeser.co.uk) is licensed under a [Creative Commons Attribution 3.0] (http://creativecommons.org/licenses/by/3.0/) Unported License, Copyright 2012.

Contributions from [Willie Oliveira] (https://github.com/willieoliveira) and [Erik Corry] (https://github.com/erikcorry)

###Syntax:

sizeToBytes(int, string);

###Arguments:

  • int Numeric value for size.
  • string Format of numeric value - Allowed formats: KB, MB, GB, TB, PB, EB, ZB, YB

###Returns:

  • int The arguments as an integer.
  • NaN The format of the number is not recognised.

###Example:

sizeToBytes(1, 'KB'); //1024
sizeToBytes(1, 'MB'); //1048576
sizeToBytes(1, 'TB'); //1099511627776

About

A simple function that returns the number of bytes in a human readable size.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published