|
- export const getListValueWithKey = (list, key, k = 'k', v = 'v') => {
- for (let i = 0, iLen = list.length; i < iLen; i++) {
- const listI = list[i];
- if (listI[k] === key) return listI[v];
- }
- return key;
- };
-
- export const getUrlSearchParams = () => {
- const params = new URLSearchParams(location.search);
- const obj = {};
- params.forEach((value, key) => {
- obj[key] = value;
- });
- return obj;
- };
-
- export const transFileSize = (srcSize) => {
- if (null == srcSize || srcSize == '') {
- return '0 Bytes';
- }
- const unitArr = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
- srcSize = parseFloat(srcSize);
- const index = Math.floor(Math.log(srcSize) / Math.log(1024));
- const size = (srcSize / Math.pow(1024, index)).toFixed(2);
- return size + ' ' + unitArr[index];
- };
|