MCPcopy Create free account
hub / github.com/XTXMarkets/ternfs / stringifySize

Function stringifySize

go/ternweb/scripts.js:310–330  ·  view source on GitHub ↗
(x)

Source from the content-addressed store, hash-verified

308}
309
310function stringifySize(x) {
311 let amount = x;
312 let unit = 'byte';
313 if (x > 1e15) {
314 amount = x/1e15;
315 unit = 'PB';
316 } else if (x > 1e12) {
317 amount = x/1e12;
318 unit = 'TB';
319 } else if (x > 1e9) {
320 amount = x/1e9;
321 unit = 'GB';
322 } else if (x > 1e6) {
323 amount = x/1e6;
324 unit = 'MB';
325 } else if (x > 1e3) {
326 amount = x/1e3;
327 unit = 'KB';
328 }
329 return amount.toFixed(2) + unit;
330}
331
332function stringifyAgo(then, now) {
333 const diffInSeconds = Math.floor((now - then) / 1000);

Callers 1

BlockServicesFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected