How to use the @build-tracker/formatting.formatBytes function in @build-tracker/formatting

To help you get started, we’ve selected a few @build-tracker/formatting examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github paularmstrong / build-tracker / src / app / src / components / ComparisonTable / DeltaCell.tsx View on Github external
if (errorBudgets.length) {
    backgroundColor = scale(danger, 1);
  } else if (warningBudgets.length) {
    backgroundColor = scale(warning, 1);
  } else if (percentDelta > 0) {
    backgroundColor = scale(danger, percentDelta);
  } else if (sizeDelta === 0 && cell.hashChanged) {
    backgroundColor = scale(warning, 0.5);
  } else if (sizeDelta !== 0) {
    backgroundColor = scale(happy, percentDelta);
  }

  const stringChange = `${sizeDelta} bytes (${(percentDelta * 100).toFixed(3)}%)`;
  const title = cell.hashChanged && sizeDelta === 0 ? `Unexpected hash change! ${stringChange}` : stringChange;

  const text = sizeDelta === 0 ? cell.hashChanged ?  : '' : formatBytes(sizeDelta);
  const tooltipText = failingBudgets.length
    ? failingBudgets.map(budget => formatBudgetResult(budget, cell.name)).join(', ')
    : sizeDelta === 0 && cell.hashChanged
    ? `The hash for "${cell.name}" unexpectedly changed`
    : `"${cell.name}" changed by ${stringChange}`;

  return (
    
      {text ? (
        // @ts-ignore
github paularmstrong / build-tracker / src / app / src / components / ComparisonTable / TotalCell.tsx View on Github external
export const TotalCell = (props: Props): React.ReactElement => {
  const { cell, sizeKey, style } = props;
  const value = cell.sizes[sizeKey];
  const text = value === 0 ? '' : formatBytes(value);
  return {text ?  : null};
};
github paularmstrong / build-tracker / src / app / src / components / Graph / YAxis.tsx View on Github external
const tickFormat = (d): string =>
  formatBytes(d.valueOf(), { formatter: (bytes: number, units: number): number => Math.round(bytes / units) });
github paularmstrong / build-tracker / src / comparator / src / index.ts View on Github external
const defaultFormatTotal = (cell: TotalCell, sizeKey: string): string => formatBytes(cell.sizes[sizeKey] || 0);
const defaultFormatDelta = (cell: DeltaCell | TotalDeltaCell, sizeKey: string): string => {

@build-tracker/formatting

Build Tracker number and string formatting tools

MIT
Latest version published 4 years ago

Package Health Score

51 / 100
Full package analysis

Similar packages