UNPKG

@taiga-ui/kit

Version:
28 lines (23 loc) 1.22 kB
(function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@taiga-ui/cdk')) : typeof define === 'function' && define.amd ? define('@taiga-ui/kit/utils/files', ['exports', '@taiga-ui/cdk'], factory) : (global = global || self, factory((global['taiga-ui'] = global['taiga-ui'] || {}, global['taiga-ui'].kit = global['taiga-ui'].kit || {}, global['taiga-ui'].kit.utils = global['taiga-ui'].kit.utils || {}, global['taiga-ui'].kit.utils.files = {}), global.cdk)); }(this, (function (exports, cdk) { 'use strict'; var BYTES_PER_KB = 1000; var BYTES_PER_MB = 1000 * BYTES_PER_KB; function formatSize(units, size) { if (size === undefined) { return null; } if (size < BYTES_PER_KB) { return size + " " + units[0]; } if (size < BYTES_PER_MB) { return (size / BYTES_PER_KB).toFixed() + " " + units[1]; } return cdk.round(size / BYTES_PER_MB, 2).toLocaleString() + " " + units[2]; } exports.formatSize = formatSize; Object.defineProperty(exports, '__esModule', { value: true }); }))); //# sourceMappingURL=taiga-ui-kit-utils-files.umd.js.map