Convert bytes to a human readable string: 1337 → 1.34 kB.
1337
1.34 kB
import formatBytes from '@oliversalzburg/js-utils/format/bytes.js';formatBytes(1337);//=> '1.34 kB'formatBytes(100);//=> '100 B'// Display file size differencesformatBytes(42, {signed: true});//=> '+42 B'// Localized output using German localeformatBytes(1337, {locale: 'de'});//=> '1,34 kB' Copy
import formatBytes from '@oliversalzburg/js-utils/format/bytes.js';formatBytes(1337);//=> '1.34 kB'formatBytes(100);//=> '100 B'// Display file size differencesformatBytes(42, {signed: true});//=> '+42 B'// Localized output using German localeformatBytes(1337, {locale: 'de'});//=> '1,34 kB'
The number to format.
The options for formatting the number.
The formatted string.
Convert bytes to a human readable string:
1337
→1.34 kB
.Example