1
0
mirror of https://github.com/ascribe/onion.git synced 2024-12-23 01:39:36 +01:00
onion/js/utils/file.js

19 lines
588 B
JavaScript
Raw Permalink Normal View History

2016-06-13 14:55:27 +02:00
// Re-export related utilities from js-utility-belt for easier access
export {
createTextFile,
computeFileHash,
extractFileExtensionFromString,
extractFileExtensionFromUrl
} from 'js-utility-belt/es6/file';
2016-07-08 16:31:26 +02:00
/**
* Transforms kb size to mb size, using an arbitrary rounding function at the end.
*
* @param {number} size Size in kb
* @param {function} roundFn Function to round out the precise size in mb, defaulting to Math.ceil.
* @return {number} Size in mb
*/
export function kbToMb(size, roundFn = Math.ceil) {
return roundFn(size / 1024);
}