filesize
JavaScript library to generate a human readable String describing the file size
Last updated 2 years ago by avoidwork .
BSD-3-Clause · Repository · Bugs · Original npm · Tarball · package.json
$ gnpm install filesize 
SYNC missed versions from official npm registry.

filesize.js

downloads CDNJS version

filesize.js provides a simple way to get a human readable file size string from a number (float or integer) or string.

import {filesize} from "filesize";
filesize(265318, {base: 2, standard: "jedec"}); // "259.1 KB"

Optional settings

filesize() accepts an optional descriptor Object as a second argument, so you can customize the output.

base

(number) Number base, default is 10

bits

(boolean) Enables bit sizes, default is false

exponent

(number) Specifies the symbol via exponent, e.g. 2 is MB for base 2, default is -1

fullform

(boolean) Enables full form of unit of measure, default is false

fullforms

(array) Array of full form overrides, default is []

locale (overrides 'separator')

(string || boolean) BCP 47 language tag to specify a locale, or true to use default locale, default is ""

localeOptions (overrides 'separator', requires string for 'locale' option)

(object) Dictionary of options defined by ECMA-402 (Number.prototype.toLocaleString). Requires locale option to be explicitly passed as a string, otherwise is ignored.

output

(string) Output of function (array, exponent, object, or string), default is string

pad

(boolean) Decimal place end padding, default is false

precision

(number) Sets precision of numerical output, default is 0

round

(number) Decimal place, default is 2

roundingMethod

(string) Rounding method, can be round, floor, or ceil, default is round

separator

(string) Decimal separator character, default is .

spacer

(string) Character between the result and symbol, default is " "

standard

(string) Standard unit of measure, can be iec or jedec, default is iec; can be overruled by base

symbols

(object) Dictionary of IEC/JEDEC symbols to replace for localization, defaults to english if no match is found

Partial Application

partial() takes the second parameter of filesize() and returns a new function with the configuration applied upon execution. This can be used to reduce Object creation if you call filesize() without caching the descriptor in lexical scope.

import {partial} from "filesize";
const size = partial({base: 2, standard: "jedec"});

size(265318); // "259.1 KB"

License

Copyright (c) 2022 Jason Mulligan Licensed under the BSD-3 license.

Current Tags

  • 10.0.6                                ...           latest (2 years ago)

111 Versions

  • 10.0.6                                ...           2 years ago
  • 10.0.5                                ...           2 years ago
  • 10.0.4                                ...           2 years ago
  • 10.0.3                                ...           2 years ago
  • 10.0.2                                ...           2 years ago
  • 10.0.1                                ...           2 years ago
  • 10.0.0                                ...           2 years ago
  • 9.0.11                                ...           2 years ago
  • 9.0.10                                ...           2 years ago
  • 9.0.9                                ...           2 years ago
  • 9.0.8                                ...           2 years ago
  • 9.0.7                                ...           2 years ago
  • 9.0.6                                ...           2 years ago
  • 9.0.4                                ...           2 years ago
  • 9.0.2                                ...           2 years ago
  • 9.0.1                                ...           3 years ago
  • 9.0.0                                ...           3 years ago
  • 8.0.7                                ...           3 years ago
  • 8.0.6                                ...           3 years ago
  • 8.0.5                                ...           3 years ago
  • 8.0.4                                ...           3 years ago
  • 8.0.3                                ...           3 years ago
  • 8.0.2                                ...           3 years ago
  • 8.0.1                                ...           3 years ago
  • 8.0.0                                ...           3 years ago
  • 7.0.0                                ...           3 years ago
  • 6.4.0                                ...           3 years ago
  • 6.3.0                                ...           4 years ago
  • 6.2.6                                ...           4 years ago
  • 6.2.5                                ...           4 years ago
  • 6.2.4                                ...           4 years ago
  • 6.2.3                                ...           4 years ago
  • 6.2.2                                ...           4 years ago
  • 6.2.1                                ...           4 years ago
  • 6.2.0                                ...           4 years ago
  • 6.1.0                                ...           5 years ago
  • 6.0.1                                ...           5 years ago
  • 6.0.0                                ...           5 years ago
  • 5.0.3                                ...           5 years ago
  • 5.0.2                                ...           5 years ago
  • 5.0.1                                ...           5 years ago
  • 5.0.0                                ...           5 years ago
  • 4.2.1                                ...           5 years ago
  • 4.2.0                                ...           5 years ago
  • 4.1.2                                ...           6 years ago
  • 4.1.1                                ...           6 years ago
  • 4.0.0                                ...           6 years ago
  • 3.6.1                                ...           7 years ago
  • 3.6.0                                ...           7 years ago
  • 3.5.11                                ...           7 years ago
  • 3.5.10                                ...           8 years ago
  • 3.5.9                                ...           8 years ago
  • 3.5.8                                ...           8 years ago
  • 3.5.7                                ...           8 years ago
  • 3.5.6                                ...           8 years ago
  • 3.5.5                                ...           8 years ago
  • 3.5.4                                ...           8 years ago
  • 3.5.3                                ...           8 years ago
  • 3.5.2                                ...           8 years ago
  • 3.5.1                                ...           8 years ago
  • 3.5.0                                ...           8 years ago
  • 3.4.3                                ...           8 years ago
  • 3.4.2                                ...           8 years ago
  • 3.4.1                                ...           8 years ago
  • 3.4.0                                ...           8 years ago
  • 3.3.0                                ...           9 years ago
  • 3.2.1                                ...           9 years ago
  • 3.2.0                                ...           9 years ago
  • 3.1.6                                ...           9 years ago
  • 3.1.5                                ...           9 years ago
  • 3.1.4                                ...           9 years ago
  • 3.1.3                                ...           9 years ago
  • 3.1.2                                ...           10 years ago
  • 3.1.1                                ...           10 years ago
  • 3.1.0                                ...           10 years ago
  • 3.0.2                                ...           10 years ago
  • 3.0.1                                ...           10 years ago
  • 3.0.0                                ...           10 years ago
  • 2.0.4                                ...           10 years ago
  • 2.0.3                                ...           11 years ago
  • 2.0.2                                ...           11 years ago
  • 2.0.1                                ...           11 years ago
  • 2.0.0                                ...           11 years ago
  • 1.10.0                                ...           11 years ago
  • 1.9.7                                ...           11 years ago
  • 1.9.6                                ...           11 years ago
  • 1.9.5                                ...           11 years ago
  • 1.9.4                                ...           11 years ago
  • 1.9.3                                ...           12 years ago
  • 1.9.2                                ...           12 years ago
  • 1.9.1                                ...           12 years ago
  • 1.9.0                                ...           12 years ago
  • 1.8.0                                ...           12 years ago
  • 1.7.9                                ...           12 years ago
  • 1.7.8                                ...           12 years ago
  • 1.7.7                                ...           12 years ago
  • 1.7.6                                ...           12 years ago
  • 1.7.5                                ...           12 years ago
  • 1.7.4                                ...           12 years ago
  • 1.7.3                                ...           12 years ago
  • 1.7.2                                ...           12 years ago
  • 1.7.1                                ...           12 years ago
  • 1.7.0                                ...           12 years ago
  • 1.6.7                                ...           12 years ago
  • 1.6.6                                ...           12 years ago
  • 1.6.5                                ...           12 years ago
  • 1.6.4                                ...           12 years ago
  • 1.6.3                                ...           13 years ago
  • 1.6.2                                ...           13 years ago
  • 1.6.1                                ...           13 years ago
  • 1.6.0                                ...           13 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (0)
None
Dev Dependencies (6)

Copyright 2013 - present © cnpmjs.org | Home |