MCPcopy Create free account
hub / github.com/angular/components / parseMinScores

Function parseMinScores

docs/tools/lighthouse-audit.mjs:220–240  ·  view source on GitHub ↗

* @param {string} raw is either a number (in which case it is interpreted as `all: `) * or a list of comma-separated strings of the form `key:value`, where `key` is one of * `accessibility`, `best-practices`, `performance`, `pwa`, `seo` or `all` and `value` is a * number (between 0 a

(raw)

Source from the content-addressed store, hash-verified

218 * @returns {{all?: number, performance?: number, accessibility?: number, 'best-practices'?: number, pwa?: number, seo?: number}} an object representing the minimum acceptable scores for each audit category
219 */
220function parseMinScores(raw) {
221 const minScores = {};
222
223 if (/^\d+$/.test(raw)) {
224 raw = `all:${raw}`;
225 }
226
227 raw
228 .split(',')
229 .map(x => x.split(':'))
230 .forEach(([key, val]) => (minScores[key] = Number(val) / 100));
231
232 if (minScores.hasOwnProperty('all')) {
233 AUDIT_CATEGORIES.forEach(
234 cat => minScores.hasOwnProperty(cat) || (minScores[cat] = minScores.all),
235 );
236 delete minScores.all;
237 }
238
239 return minScores;
240}
241
242/**
243 * @param results from a Lighthouse run

Callers 1

parseInputFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected