Socket
Socket
Sign inDemoInstall

filesize

Package Overview
Dependencies
Maintainers
1
Versions
124
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

filesize - npm Package Compare versions

Comparing version 1.9.7 to 1.10.0

6

lib/filesize.js

@@ -9,3 +9,3 @@ /**

* @module filesize
* @version 1.9.7
* @version 1.10.0
*/

@@ -24,7 +24,7 @@ ( function ( global ) {

all : {
increments : [["B", 1], ["kb", 128], ["kB", 1024], ["Mb", 131072], ["MB", 1048576], ["Gb", 134217728], ["GB", 1073741824], ["Tb", 137438953472], ["TB", 1099511627776], ["Pb", 140737488355328], ["PB", 1125899906842624]],
increments : [["B", 1], ["kb", 125], ["kB", 1000], ["Mb", 125000], ["MB", 1000000], ["Gb", 125000000], ["GB", 1000000000], ["Tb", 125000000000], ["TB", 1000000000000], ["Pb", 125000000000000], ["PB", 1000000000000000]],
nth : 11
},
bitless : {
increments : [["B", 1], ["kB", 1024], ["MB", 1048576], ["GB", 1073741824], ["TB", 1099511627776], ["PB", 1125899906842624]],
increments : [["B", 1], ["kB", 1000], ["MB", 1000000], ["GB", 1000000000], ["TB", 1000000000000], ["PB", 1000000000000000]],
nth : 6

@@ -31,0 +31,0 @@ }

{
"name": "filesize",
"description": "JavaScript library to generate a human readable String describing the file size",
"version": "1.9.7",
"version": "1.10.0",
"homepage": "http://filesizejs.com",

@@ -6,0 +6,0 @@ "author": {

[![build status](https://secure.travis-ci.org/avoidwork/filesize.js.png)](http://travis-ci.org/avoidwork/filesize.js)
# filesize.js
filesize.js provides a simple way to get a human readable file size string from a number (float or integer) or string. An optional second parameter is the decimal place to round to (default is 2), or _true_ which triggers Unix style output. An optional third parameter lets you disable `bit` sizes, e.g. "Kb".
filesize.js provides a simple way to get a human readable file size string from a number (float or integer) or string. An optional second parameter is the decimal place to round to (default is 2), or _true_ which triggers Unix style output. An optional third parameter lets you disable `bit` sizes, e.g. "kb".
## Examples
1.10.0 switched to base 10, all previous versions use base 2.
```javascript
filesize(500); // "3.91 Kb"
filesize(500, true); // "3.9k"
filesize(1500); // "1.46 KB"
filesize("1500000000"); // "1.40 GB"
filesize("1500000000", 0); // "1 GB"
filesize(1212312421412412); // "1.08 PB"
filesize(500); // "4.00 Kb"
filesize(500, true); // "4.0k"
filesize(1500); // "1.50 KB"
filesize("1500000000"); // "1.50 GB"
filesize("1500000000", 0); // "2GB"
filesize(1212312421412412); // "1.21 PB PB"
filesize(1212312421412412, true); // "1.1P" - shorthand output, similar to "ls -h"
filesize(265318, 2, false) // "259.10 KB" - disabled `bit` sizes with third argument
filesize(265318, 2, false) // "265.32 kB" - disabled `bit` sizes with third argument
```

@@ -18,0 +20,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc