95eeed52e4
- introduce view specific helper.mjs module - clean up some imports Bug: v8:10644 Change-Id: I0497c1a962c90f61f2beca667aca4a3f53a11e59 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2545705 Reviewed-by: Sathya Gunasekaran <gsathya@chromium.org> Commit-Queue: Camillo Bruni <cbruni@chromium.org> Cr-Commit-Position: refs/heads/master@{#71269}
27 lines
737 B
JavaScript
27 lines
737 B
JavaScript
// 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.
|
|
|
|
export const KB = 1024;
|
|
export const MB = KB * KB;
|
|
export const GB = MB * KB;
|
|
export const kMillis2Seconds = 1 / 1000;
|
|
|
|
export function formatBytes(bytes) {
|
|
const units = ['B', 'KiB', 'MiB', 'GiB'];
|
|
const divisor = 1024;
|
|
let index = 0;
|
|
while (index < units.length && bytes >= divisor) {
|
|
index++;
|
|
bytes /= divisor;
|
|
}
|
|
return bytes.toFixed(2) + units[index];
|
|
}
|
|
|
|
export function formatSeconds(millis) {
|
|
return (millis * kMillis2Seconds).toFixed(2) + 's';
|
|
}
|
|
|
|
export function delay(time) {
|
|
return new Promise(resolver => setTimeout(resolver, time));
|
|
} |