What is @lhci/utils?
@lhci/utils is a utility library for Lighthouse CI (LHCI), which is a tool for running Lighthouse audits on your codebase and tracking the results over time. This package provides various utilities to facilitate the use of LHCI, including configuration management, data handling, and result processing.
What are @lhci/utils's main functionalities?
Configuration Management
This feature allows you to load and parse the LHCI configuration file. The code sample demonstrates how to load the configuration using the `loadAndParseRcFile` function.
const { loadAndParseRcFile } = require('@lhci/utils');
const config = loadAndParseRcFile();
console.log(config);
Data Handling
This feature allows you to create a temporary Lighthouse Result (LHR) object. The code sample demonstrates how to create a temporary LHR using the `createTemporaryLhr` function.
const { createTemporaryLhr } = require('@lhci/utils');
const lhr = createTemporaryLhr({
requestedUrl: 'https://example.com',
finalUrl: 'https://example.com',
audits: {},
categories: {},
configSettings: {},
runWarnings: [],
timing: {},
i18n: {},
environment: {},
});
console.log(lhr);
Result Processing
This feature allows you to process Lighthouse run results to find the median run. The code sample demonstrates how to use the `getMedianRun` function to find the median run from an array of Lighthouse run results.
const { getMedianRun } = require('@lhci/utils');
const runs = [/* array of Lighthouse run results */];
const medianRun = getMedianRun(runs);
console.log(medianRun);
Other packages similar to @lhci/utils
lighthouse
Lighthouse is an open-source, automated tool for improving the quality of web pages. It can be run as a Node module or from the command line. While @lhci/utils provides utilities specifically for Lighthouse CI, the lighthouse package itself is used for running Lighthouse audits and generating reports.
lighthouse-ci
Lighthouse CI (LHCI) is a tool for running Lighthouse audits on your codebase and tracking the results over time. It includes a server and CLI for managing Lighthouse runs and storing results. While @lhci/utils provides utility functions to support LHCI, lighthouse-ci is the main package for setting up and running Lighthouse CI.
lighthouse-batch
Lighthouse Batch is a tool for running multiple Lighthouse audits in parallel. It is useful for auditing multiple URLs at once. While @lhci/utils provides utilities for handling individual Lighthouse runs and configurations, lighthouse-batch focuses on running multiple audits concurrently.