mirror of
https://github.com/pure-css/pure.git
synced 2024-11-24 10:44:21 +00:00
27 lines
677 B
JavaScript
27 lines
677 B
JavaScript
/**
|
|
* Calculates filesize for a given module
|
|
*/
|
|
export function fileSize({ module, decimals = 1, filesizes }) {
|
|
const filesize = (filesizes[module] / 1024);
|
|
return filesize.toFixed(decimals) + 'KB';
|
|
}
|
|
|
|
/**
|
|
* Calculates the module percentage size against all modules
|
|
*/
|
|
export function filePercent({ modules, module, filesizes }) {
|
|
const total = modules.reduce((size, m) => {
|
|
return size + filesizes[m];
|
|
}, 0);
|
|
return (filesizes[module] / total * 100).toFixed(4) + '%';
|
|
}
|
|
|
|
/**
|
|
* Generic click handler for pages
|
|
*/
|
|
export function handleClick(e) {
|
|
e.preventDefault();
|
|
e.stopPropagation();
|
|
e.nativeEvent.stopImmediatePropagation();
|
|
}
|