MCPcopy
hub / github.com/dropzone/dropzone / filesize

Method filesize

src/dropzone.js:579–601  ·  view source on GitHub ↗
(size)

Source from the content-addressed store, hash-verified

577
578 // Returns a nicely formatted filesize
579 filesize(size) {
580 let selectedSize = 0;
581 let selectedUnit = "b";
582
583 if (size > 0) {
584 let units = ["tb", "gb", "mb", "kb", "b"];
585
586 for (let i = 0; i < units.length; i++) {
587 let unit = units[i];
588 let cutoff = Math.pow(this.options.filesizeBase, 4 - i) / 10;
589
590 if (size >= cutoff) {
591 selectedSize = size / Math.pow(this.options.filesizeBase, 4 - i);
592 selectedUnit = unit;
593 break;
594 }
595 }
596
597 selectedSize = Math.round(10 * selectedSize) / 10; // Cutting of digits
598 }
599
600 return `<strong>${selectedSize}</strong> ${this.options.dictFileSizeUnits[selectedUnit]}`;
601 }
602
603 // Adds or removes the `dz-max-files-reached` class from the form.
604 _updateMaxFilesReachedClass() {

Callers 2

test.jsFile · 0.80
addedfileFunction · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected