You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I just add some features showing the file count in folder and file size, downloaded zip size and git clone size.I don't know whether those data is redundant.
it's easy to implement, when the node type is tree,calculate all the node count of this tree recusively. when the node type if blob, humanFilesize the node.size varible
zip size is the size when you click download as zip button, recusively add up all the node.size under root node
the clone size is size one repo takes in github server(not you run git clone all the files size), you could see you own repo size in https://github.com/settings/repositories. this size comes from https://api.github.com/repos/OWNER/REPO api
some of the format size code
//one file size formatterexportfunctionhumanFileSize(bytes:number,si=true,dp=1){if(bytes===null||bytes===undefined){return''}constthresh=si ? 1000 : 1024;if(Math.abs(bytes)<thresh){returnbytes+' B';}constunits=si
? ['kB','MB','GB','TB','PB','EB','ZB','YB']
: ['KiB','MiB','GiB','TiB','PiB','EiB','ZiB','YiB'];letu=-1;constr=10**dp;do{bytes/=thresh;++u;}while(Math.round(Math.abs(bytes)*r)/r>=thresh&&u<units.length-1);returnbytes.toFixed(dp)+' '+units[u];}// get the repo's zip sizeexportfunctioncalculateTotalSize(data){lettotal=0;consttraverse=(nodes)=>{for(constnodeofnodes){if(node.type==='blob'&&typeofnode.size==='number'){total+=node.size;}elseif(node.type==='tree'&&node.contents){traverse(node.contents);}}};traverse(data.nodes);returntotal;}//format the size through `https://api.github.com/repos/OWNER/REPO` apiexportfunctionformatKiloFileSize(kilobytes){constunits=['KB','MB','GB','TB','PB'];letsize=kilobytes;letunitIndex=0;while(size>=1024&&unitIndex<units.length-1){size/=1024;unitIndex++;}constformattedSize=size.toFixed(2).replace(/\.?0+$/,'');return`${formattedSize}${units[unitIndex]}`;}
The text was updated successfully, but these errors were encountered:
I just add some features showing the file count in folder and file size, downloaded zip size and git clone size.I don't know whether those data is redundant.
it's easy to implement, when the node type is
tree
,calculate all the node count of this tree recusively. when the node type ifblob
,humanFilesize
thenode.size
variblezip size is the size when you click download as zip button, recusively add up all the
node.size
under root nodethe clone size is size one repo takes in github server(not you run git clone all the files size), you could see you own repo size in https://github.com/settings/repositories. this size comes from
https://api.github.com/repos/OWNER/REPO
apisome of the format size code
The text was updated successfully, but these errors were encountered: