| 1234567891011121314151617181920212223 |
- export function bytesToSize (bytes) {
- const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB']
- if (bytes === 0) return 'n/a'
- const i = parseInt(Math.floor(Math.log(bytes) / Math.log(1024)))
- if (i === 0) return bytes + ' ' + sizes[i]
- return (bytes / Math.pow(1024, i)).toFixed(1) + ' ' + sizes[i]
- }
- export function vaildData (key, defaultValue = Boolean) {
- if (key) {
- return true
- } else {
- return defaultValue
- }
- }
- export function objectToParams (objs) {
- const query = []
- for (const k in objs) {
- query.push(k + '=' + objs[k])
- }
- return query.join('&')
- }
|