3 export const sum = function(items, prop){
4 return items.reduce( function(a, b){
5 return a + Number(_.get(b,prop))
9 export const formatBytes = function(bytes,decimals) {
10 if (bytes == 0) return '0 Bytes'
12 dm = decimals <= 0 ? 0 : decimals || 2,
13 sizes = ['B', 'KB', 'MB', 'GB', 'TB'],
14 i = Math.floor(Math.log(bytes) / Math.log(k))
15 return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + ' ' + sizes[i]
18 export const splitSlice = function (str, len) {
20 for (let offset = 0, strLen = str.length; offset < strLen; offset += len) {
21 ret.push(str.slice(offset, len + offset))