// Copyright 2020 the V8 project authors. All rights reserved.// Use of this source code is governed by a BSD-style license that can be// found in the LICENSE file.constKB=1024;constMB=KB*KB;constGB=MB*KB;constkMillis2Seconds=1/1000;functionformatBytes(bytes){constunits=[' B',' KB',' MB',' GB'];constdivisor=1024;letindex=0;while(index<units.length&&bytes>=divisor){index++;bytes/=divisor;}returnbytes.toFixed(2)+units[index];}functionformatSeconds(millis){return(millis*kMillis2Seconds).toFixed(2)+'s';}functiondefineCustomElement(name,generator){lethtmlTemplatePath=name+'-template.html';fetch(htmlTemplatePath).then(stream=>stream.text()).then(templateText=>customElements.define(name,generator(templateText)));}