ep.i18n.formatBytes()
Categories: Utilities
ep.i18n.formatBytes( value, [ decimals ], [ options ] )
Plugin: ep.i18n
Description: Format a number as Bytes.
-
ep.i18n.formatBytes( value, [ decimals ], [ options ] )
version added: 6.11.0value A number to format.
decimals A count of after decimal places.
options A map of key/values settings like the options of jQuery.i18n.formatNumber().
The ep.i18n.formatBytes()
method uses the jQuery.i18n.formatNumber()
method to format the givn value and
add the correct unit (Byte, kB, MB, GB).
- default adds Byte
- value is bigger or equal 1024 and smaller than 1048576 adds kb
- value is bigger or equal 1048576 and smaller than 1073741824 adds 'MBÃ'
- value is bigger or equal 1073741824 adds GB
-
Format an number with default options.
Code:
ep.i18n.formatBytes( 12000 );
Results:
11.72 kB
-
Format an number with 4 after decimal places.
Code:
ep.i18n.formatBytes( 10240, 4 );
Results:
10.0000 kB
-
Format an number with 2 after decimal places and german language settings.
Code:
ep.i18n.formatBytes( 10240, 2, {region: 'de'} );
Results:
10,00 kB