/* * Exposes number format capability * * @copyright Copyright (c) 2013 Kevin van Zonneveld (http://kvz.io) and Contributors (http://phpjs.org/authors). * @license See CREDITS.md * @see https://github.com/kvz/phpjs/blob/ffe1356af23a6f2512c84c954dd4e828e92579fa/functions/strings/number_format.js */ function toFixedFix( n, prec ) { const k = Math.pow( 10, prec ); return '' + ( Math.round( n * k ) / k ).toFixed( prec ); }
const formatSize = size => { let sizes = [[2, 'M'], [1, 'k']]; while (sizes.length) { let checkSize = sizes.shift(); let limit = Math.pow(1024, checkSize[0]); if (size > limit) { return `${(size / limit).toFixed(2)} ${checkSize[1]}B` } } return `${size} B`; }
var logDuration = function (d, prefix) { var str = d > 1000 ? (d / 1000).toFixed(2) + 'sec' : d + 'ms' return '\x1b[33m- ' + (prefix ? prefix + ' ' : '') + str + '\x1b[0m' }
function bytesFormatter(size) { const i = size === 0 ? 0 : Math.floor(Math.log(size) / Math.log(1024)); return (size / Math.pow(1024, i)).toFixed(2) * 1 + ' ' + ['B', 'kB', 'MB', 'GB', 'TB'][i]; }
function dollars(value, price = 1) { return '$' + (Number(value) * price).toFixed(2); }
function bytesFormatter(size) { const i = size === 0 ? 0 : Math.floor(Math.log(size) / Math.log(1024)); return (size / Math.pow(1024, i)).toFixed(2) * 1 + ' ' + ['B', 'kB', 'MB', 'GB', 'TB'][i]; }
function dollars(value, price = 1) { return '$' + (Number(value) * price).toFixed(2); }
const displayPrice = (price) => { return (price / 100).toFixed(2); }