-
-
Notifications
You must be signed in to change notification settings - Fork 877
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: github-workflow to autogenerate docs from codebase's comments
- Loading branch information
Showing
2 changed files
with
17 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,28 @@ | ||
import { promises } from 'dns'; | ||
import type { MetricType } from 'web-vitals'; | ||
|
||
/** | ||
* Reports web performance metrics to the console. | ||
* | ||
* @param {Function} [onPerfEntry] - Optional callback function | ||
* that will be called with the metric object for each metric. | ||
* The function should have the following signature: | ||
* (metric: MetricType) => void | ||
*/ | ||
const reportWebVitals = (onPerfEntry?: (metric: MetricType) => void): void => { | ||
if (onPerfEntry && onPerfEntry instanceof Function) { | ||
import('web-vitals').then(({ onCLS, onFCP, onLCP, onTTFB }) => { | ||
// Reports the CLS (Cumulative Layout Shift) metric. | ||
onCLS(onPerfEntry); | ||
|
||
// Reports the FCP (First Contentful Paint) metric. | ||
onFCP(onPerfEntry); | ||
|
||
// Reports the LCP (Largest Contentful Paint) metric. | ||
onLCP(onPerfEntry); | ||
|
||
// Reports the TTFB (Time to First Byte) metric. | ||
onTTFB(onPerfEntry); | ||
}); | ||
} | ||
}; | ||
|
||
export default reportWebVitals; | ||
|