Skip to content

Chrome DevTools for coding agents

fix(performance): ImageDelivery insight errors (#144)

Jack Franklind64ba0d90275
diff --git a/scripts/post-build.ts b/scripts/post-build.ts
index 21a15a07..b77204ca 100644
--- a/scripts/post-build.ts
+++ b/scripts/post-build.ts
@@ -101,6 +101,30 @@ export const TimeUtilities = {
}
}
+ return parts.map(part => part.value).join('');
+ }
+};
+
+// TODO(jacktfranklin): once the ImageDelivery insight does not depend on this method, we can remove this stub.
+export const ByteUtilities = {
+ bytesToString(x) {
+ const separator = '\xA0';
+ const formatter = new Intl.NumberFormat('en-US', {
+ style: 'unit',
+ unit: 'kilobyte',
+ unitDisplay: 'narrow',
+ minimumFractionDigits: 1,
+ maximumFractionDigits: 1,
+ });
+ const parts = formatter.formatToParts(x / 1000);
+ for (const part of parts) {
+ if (part.type === 'literal') {
+ if (part.value === ' ') {
+ part.value = separator;
+ }
+ }
+ }
+
return parts.map(part => part.value).join('');
}
};`;