Skip to content

Commit

Permalink
Changing the method of generating result
Browse files Browse the repository at this point in the history
  • Loading branch information
avoidwork committed Mar 1, 2014
1 parent d5a1f9d commit 98f34a1
Show file tree
Hide file tree
Showing 9 changed files with 102 additions and 92 deletions.
2 changes: 1 addition & 1 deletion Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ module.exports = function(grunt) {
"<banner>",
"src/intro.js",
"src/filesize.js",
"src/options.js",
"src/si.js",
"src/outro.js"
],
dest : "lib/filesize.js"
Expand Down
86 changes: 42 additions & 44 deletions lib/filesize.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,12 @@
* @license BSD-3 <https://raw.github.com/avoidwork/filesize.js/master/LICENSE>
* @link http://filesizejs.com
* @module filesize
* @version 2.0.1
* @version 2.0.2
*/
( function ( global ) {
"use strict";

var bit = /b$/,
bite = /^B$/,
radix = 10,
right = /\.(.*)/,
zero = /^0$/;
Expand All @@ -28,8 +27,7 @@ var bit = /b$/,
function filesize ( arg, descriptor ) {
var result = "",
skip = false,
i = 6,
base, bits, neg, num, round, size, sizes, unix, spacer, suffix, z, suffixes;
e, base, bits, ceil, neg, num, round, unix, spacer, suffix, z, suffixes;

if ( isNaN( arg ) ) {
throw new Error( "Invalid arguments" );
Expand All @@ -44,6 +42,7 @@ function filesize ( arg, descriptor ) {
suffixes = descriptor.suffixes !== undefined ? descriptor.suffixes : {};
num = Number( arg );
neg = ( num < 0 );
ceil = base > 2 ? 1000 : 1024;

// Flipping a negative number to determine the size
if ( neg ) {
Expand All @@ -61,45 +60,50 @@ function filesize ( arg, descriptor ) {
}
}
else {
sizes = options[base][bits ? "bits" : "bytes"];
e = Math.floor( Math.log( num ) / Math.log( 1000 ) );

while ( i-- ) {
size = sizes[i][1];
suffix = sizes[i][0];

if ( num >= size ) {
// Treating bytes as cardinal
if ( bite.test( suffix ) ) {
skip = true;
round = 0;
}
if ( base === 2 ) {
result = num / Math.pow( 2, ( e * 10 ) );
}
else {
result = num / Math.pow( 1000, e );
}

result = ( num / size ).toFixed( round );
if ( bits ) {
result = ( result * 8 );

if ( !skip && unix ) {
if ( bits && bit.test( suffix ) ) {
suffix = suffix.toLowerCase();
}
if ( result > ceil ) {
result = result / ceil;
e++;
}
}

suffix = suffix.charAt( 0 );
z = right.exec( result );
result = result.toFixed( e > 0 ? round : 0 );
suffix = si[bits ? "bits" : "bytes"][e];

if ( !bits && suffix === "k" ) {
suffix = "K";
}
if ( !skip && unix ) {
if ( bits && bit.test( suffix ) ) {
suffix = suffix.toLowerCase();
}

if ( z !== null && z[1] !== undefined && zero.test( z[1] ) ) {
result = parseInt( result, radix );
}
suffix = suffix.charAt( 0 );
z = right.exec( result );

result += spacer + ( suffixes[suffix] || suffix );
}
else if ( !unix ) {
result += spacer + ( suffixes[suffix] || suffix );
}
if ( suffix === "B" ) {
suffix = "";
}
else if ( !bits && suffix === "k" ) {
suffix = "K";
}

break;
if ( z !== null && z[1] !== undefined && zero.test( z[1] ) ) {
result = parseInt( result, radix );
}

result += spacer + ( suffixes[suffix] || suffix );
}
else if ( !unix ) {
result += spacer + ( suffixes[suffix] || suffix );
}
}

Expand All @@ -112,19 +116,13 @@ function filesize ( arg, descriptor ) {
}

/**
* Size options
* SI suffixes
*
* @type {Object}
*/
var options = {
2 : {
bits : [["B", 1], ["kb", 128], ["Mb", 131072], ["Gb", 134217728], ["Tb", 137438953472], ["Pb", 140737488355328]],
bytes : [["B", 1], ["kB", 1024], ["MB", 1048576], ["GB", 1073741824], ["TB", 1099511627776], ["PB", 1125899906842624]]
},
10 : {
bits : [["B", 1], ["kb", 125], ["Mb", 125000], ["Gb", 125000000], ["Tb", 125000000000], ["Pb", 125000000000000]],
bytes : [["B", 1], ["kB", 1000], ["MB", 1000000], ["GB", 1000000000], ["TB", 1000000000000], ["PB", 1000000000000000]]
}
var si = {
bits : ["B", "kb", "Mb", "Gb", "Tb", "Pb"],
bytes : ["B", "kB", "MB", "GB", "TB", "PB"]
};

// CommonJS, AMD, script tag
Expand Down
6 changes: 3 additions & 3 deletions lib/filesize.map
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"version":3,
"file":"filesize.min.js",
"lineCount":10,
"mappings":"A;;;;;;;AAUE,SAAS,CAAEA,CAAF,CAAW,CAiBtBC,QAASA,EAAS,CAAEC,CAAF,CAAOC,CAAP,CAAoB,CAAA,IACjCC,EAAS,EADwB,CAEjCC,EAAS,CAAA,CAFwB,CAGjCC,EAAS,CAHwB,CAIjCC,CAJiC,CAI3BC,CAJ2B,CAIrBC,CAJqB,CAIhBC,CAJgB,CAIXC,CAJW,CAIJC,CAJI,CAIEC,CAJF,CAISC,CAJT,CAIeC,CAJf,CAIkCC,CAEvE,IAAKC,KAAA,CAAOf,CAAP,CAAL,CACC,KAAUgB,MAAJ,CAAW,mBAAX,CAAN,CAGDf,CAAA,CAAaA,CAAb,EAA2B,EAC3BK,EAAA,CAAmC,CAAA,CAAnC,GAAeL,CAAAK,KACfM,EAAA,CAAmC,CAAA,CAAnC,GAAeX,CAAAW,KACfP,EAAA,CAAqCY,IAAAA,EAAxB,GAAAhB,CAAAI,KAAA,CAAoCJ,CAAAI,KAApC,CAA0DO,CAAA,CAAO,CAAP,CAAY,EACnFH,EAAA,CAAqCQ,IAAAA,EAAxB,GAAAhB,CAAAQ,MAAA,CAAoCR,CAAAQ,MAApC,CAA0DG,CAAA,CAAO,CAAP,CAAY,CACnFC,EAAA,CAAqCI,IAAAA,EAAxB,GAAAhB,CAAAY,OAAA,CAAoCZ,CAAAY,OAApC,CAA0DD,CAAA,CAAO,EAAP,CAAY,GACnFE,EAAA,CAAqCG,IAAAA,EAAxB,GAAAhB,CAAAa,SAAA,CAAoCb,CAAAa,SAApC,CAA0D,EACvEN,EAAA,CAAaU,MAAA,CAAQlB,CAAR,CAIb,EAHAO,CAGA,CAHqB,CAGrB,CAHeC,CAGf,IACCA,CADD,CACO,CAACA,CADR,CAKA,IAAa,CAAb,GAAKA,CAAL,CACMI,CAAL,CACCV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AAAA,EAI5B,GAJmBa,CAAA,CAAE,CAAF,CAInB,EAJyCG,CAAAN,KAAA,CAAWG,CAAA,CAAE,CAAF,CAAX,CAIzC,GAHC1B,CAGD,CAHU8B,QAAA,CAAU9B,CAAV,CAAkB+B,CAAlB,CAGV,EAAA/B,CAAA,EAAUQ,CAAV,EAAqBC,CAAA,CAASM,CAAT,CAArB,EAAyCA,CAAzC,CAnBD,EAqBWR,CArBX,GAsBCP,CAtBD,EAsBWQ,CAtBX,EAsBsBC,CAAA,CAASM,CAAT,CAtBtB,EAsB0CA,CAtB1C,EA/BD,CA0DKX,EAAL,GACCJ,CADD,CACU,GADV,CACgBA,CADhB,CAIA,OAAOA,EAxF8B,CAhBhB,IAGlBsB,EAAQ,IAHU,CAIlBS,EAAQ,EAJU,CAKlBJ,EAAQ,QALU,CAMlBE,EAAQ,KANU,CAgHlBR,EAAK,MACA,kBAAA,MAAA,CAAA,GAAA,CADA,OAEA,kBAAA,MAAA,CAAA,GAAA,CAFA,CAMe,YAAxB,GAAK,MAAOW,QAAZ,CACCC,MAAAD,QADD,CACkBnC,CADlB,CAG4B,UAAvB,GAAK,MAAOqC,OAAZ,CACJA,MAAA,CAAQ,QAAS,EAAG,CACnB,MAAOrC,EADY,CAApB,CADI,CAMJD,CAAAC,SANI,CAMcA,CA/HG,CAApB,CAAA,CAkIG,IAlIH;",
"sources":["filesize.js"],
"names":["global","filesize","arg","descriptor","result","skip","i","base","bits","neg","num","round","size","sizes","unix","spacer","suffixes","isNaN","Error","undefined","Number","suffix","options","bite","test","toFixed","bit","toLowerCase","charAt","z","right","exec","zero","parseInt","radix","exports","module","define"]
"names":["global","filesize","arg","descriptor","result","e","bits","ceil","neg","num","round","unix","spacer","suffixes","isNaN","Error","base","undefined","Number","suffix","Math","floor","log","pow","toFixed","si","bit","test","toLowerCase","charAt","z","right","exec","zero","parseInt","radix","exports","module","define"]
}
7 changes: 3 additions & 4 deletions lib/filesize.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "filesize",
"description": "JavaScript library to generate a human readable String describing the file size",
"version": "2.0.1",
"version": "2.0.2",
"homepage": "http://filesizejs.com",
"author": {
"name": "Jason Mulligan",
Expand Down
69 changes: 37 additions & 32 deletions src/filesize.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
function filesize ( arg, descriptor ) {
var result = "",
skip = false,
i = 6,
base, bits, neg, num, round, size, sizes, unix, spacer, suffix, z, suffixes;
e, base, bits, ceil, neg, num, round, unix, spacer, suffix, z, suffixes;

if ( isNaN( arg ) ) {
throw new Error( "Invalid arguments" );
Expand All @@ -25,6 +24,7 @@ function filesize ( arg, descriptor ) {
suffixes = descriptor.suffixes !== undefined ? descriptor.suffixes : {};
num = Number( arg );
neg = ( num < 0 );
ceil = base > 2 ? 1000 : 1024;

// Flipping a negative number to determine the size
if ( neg ) {
Expand All @@ -42,45 +42,50 @@ function filesize ( arg, descriptor ) {
}
}
else {
sizes = options[base][bits ? "bits" : "bytes"];
e = Math.floor( Math.log( num ) / Math.log( 1000 ) );

while ( i-- ) {
size = sizes[i][1];
suffix = sizes[i][0];

if ( num >= size ) {
// Treating bytes as cardinal
if ( bite.test( suffix ) ) {
skip = true;
round = 0;
}
if ( base === 2 ) {
result = num / Math.pow( 2, ( e * 10 ) );
}
else {
result = num / Math.pow( 1000, e );
}

result = ( num / size ).toFixed( round );
if ( bits ) {
result = ( result * 8 );

if ( !skip && unix ) {
if ( bits && bit.test( suffix ) ) {
suffix = suffix.toLowerCase();
}
if ( result > ceil ) {
result = result / ceil;
e++;
}
}

suffix = suffix.charAt( 0 );
z = right.exec( result );
result = result.toFixed( e > 0 ? round : 0 );
suffix = si[bits ? "bits" : "bytes"][e];

if ( !bits && suffix === "k" ) {
suffix = "K";
}
if ( !skip && unix ) {
if ( bits && bit.test( suffix ) ) {
suffix = suffix.toLowerCase();
}

if ( z !== null && z[1] !== undefined && zero.test( z[1] ) ) {
result = parseInt( result, radix );
}
suffix = suffix.charAt( 0 );
z = right.exec( result );

result += spacer + ( suffixes[suffix] || suffix );
}
else if ( !unix ) {
result += spacer + ( suffixes[suffix] || suffix );
}
if ( suffix === "B" ) {
suffix = "";
}
else if ( !bits && suffix === "k" ) {
suffix = "K";
}

break;
if ( z !== null && z[1] !== undefined && zero.test( z[1] ) ) {
result = parseInt( result, radix );
}

result += spacer + ( suffixes[suffix] || suffix );
}
else if ( !unix ) {
result += spacer + ( suffixes[suffix] || suffix );
}
}

Expand Down
1 change: 0 additions & 1 deletion src/intro.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"use strict";

var bit = /b$/,
bite = /^B$/,
radix = 10,
right = /\.(.*)/,
zero = /^0$/;
9 changes: 9 additions & 0 deletions src/si.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/**
* SI suffixes
*
* @type {Object}
*/
var si = {
bits : ["B", "kb", "Mb", "Gb", "Tb", "Pb"],
bytes : ["B", "kB", "MB", "GB", "TB", "PB"]
};
12 changes: 6 additions & 6 deletions test/filesize_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ exports["filesize"] = {
test.equal(filesize(this.byte, {base: 2, round: 1}), "1 B", "Should be '1 B'");
test.equal(filesize(this.byte, {base: 2, round: 1, spacer: ""}), "1B", "Should be '1B'");
test.equal(filesize(this.byte, {base: 2, unix: true}), "1", "Should be '1'");
test.equal(filesize(this.byte, {base: 2, bits :true}), "1 B", "Should be '1 B'");
test.equal(filesize(this.byte, {base: 2, round: 1, bits: true}), "1 B", "Should be '1 B'");
test.equal(filesize(this.byte, {base: 2, unix: true, bits: true}), "1", "Should be '1'");
test.equal(filesize(this.byte, {base: 2, bits :true}), "8 B", "Should be '8 B'");
test.equal(filesize(this.byte, {base: 2, round: 1, bits: true}), "8 B", "Should be '8 B'");
test.equal(filesize(this.byte, {base: 2, unix: true, bits: true}), "8", "Should be '8'");

test.equal(filesize(this.zero, {base: 2, base: 2}), "0 B", "Should be '0 B'");
test.equal(filesize(this.zero, {base: 2, round: 1}), "0 B", "Should be '0 B'");
Expand Down Expand Up @@ -86,9 +86,9 @@ exports["filesize"] = {
test.equal(filesize(this.byte, {round: 1}), "1 B", "Should be '1 B'");
test.equal(filesize(this.byte, {round: 1, spacer: ""}), "1B", "Should be '1B'");
test.equal(filesize(this.byte, {unix: true}), "1", "Should be '1'");
test.equal(filesize(this.byte, {bits :true}), "1 B", "Should be '1 B'");
test.equal(filesize(this.byte, {round: 1, bits: true}), "1 B", "Should be '1 B'");
test.equal(filesize(this.byte, {unix: true, bits: true}), "1", "Should be '1'");
test.equal(filesize(this.byte, {bits :true}), "8 B", "Should be '8 B'");
test.equal(filesize(this.byte, {round: 1, bits: true}), "8 B", "Should be '8 B'");
test.equal(filesize(this.byte, {unix: true, bits: true}), "8", "Should be '8'");

test.equal(filesize(this.zero), "0 B", "Should be '0 B'");
test.equal(filesize(this.zero, {round: 1}), "0 B", "Should be '0 B'");
Expand Down

0 comments on commit 98f34a1

Please sign in to comment.