Bytes formatter module from Glize library.
npm install bytes-formatter --save
import { formatBytes } from 'bytes-formatter';
/**
* Formats given <code>bytes</code> to human friendly format.
* @param {number} bytes The bytes to be formatted.
* @return {string} The formatted bytes as string.
*/
console.log(formatBytes(1024)); // 1.0 KB
For more information please visit Glize project page.