async function convertBudgetsToAssertions(budgets) {
  // Normalize the definition using built-in Lighthouse validation.
  budgets = Budget.initializeBudget(budgets);

  /** @type {Array<LHCI.AssertCommand.BaseOptions>} */
  const assertMatrix = [];

  for (const budget of budgets) {
    /** @type {LHCI.AssertCommand.Assertions} */
    const assertions = {};

    for (const {metric, budget: maxNumericValue} of budget.timings || []) {
      assertions[metric] = ['error', {maxNumericValue}];
    }

    for (const {resourceType, budget: maxNumericValue} of budget.resourceCounts || []) {
      assertions[`resource-summary:${resourceType}:count`] = ['error', {maxNumericValue}];
    }

    for (const {resourceType, budget: maxNumericValue} of budget.resourceSizes || []) {
      assertions[`resource-summary:${resourceType}:size`] = [
        'error',
        {maxNumericValue: maxNumericValue * 1024},
      ];
    }

    assertMatrix.push({
      matchingUrlPattern: convertPathExpressionToRegExp(budget.path).source,
      assertions,
    });
  }

  return {assertMatrix};
}
@param {Array<LHCI.AssertCommand.Budget>} budgets
@return {Promise<LHCI.AssertCommand.Options>}