UNPKG

react-middleware

Version:

Connect middleware for serving React components from a standard folder structure.

22 lines (19 loc) 696 B
"use strict"; // See: http://stackoverflow.com/a/14919494/1745661 Object.defineProperty(exports, "__esModule", { value: true }); var fileSize = exports.fileSize = function fileSize(bytes) { var si = arguments.length <= 1 || arguments[1] === undefined ? true : arguments[1]; var thresh = si ? 1000 : 1024; if (Math.abs(bytes) < thresh) { return bytes + ' B'; } var units = si ? ['KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'] : ['KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB']; var u = -1; do { bytes /= thresh; ++u; } while (Math.abs(bytes) >= thresh && u < units.length - 1); return '' + bytes.toFixed(1) + units[u]; };