Home / Function/ filterPreloads() — astro Function Reference

filterPreloads() — astro Function Reference

Architecture documentation for the filterPreloads() function in filter-preloads.ts from the astro codebase.

Entity Profile

Dependency Diagram

graph TD
  89cb31aa_5261_3d6d_adae_891147154070["filterPreloads()"]
  b779aa4c_fa5b_6be0_853d_7e9457320b63["filter-preloads.ts"]
  89cb31aa_5261_3d6d_adae_891147154070 -->|defined in| b779aa4c_fa5b_6be0_853d_7e9457320b63
  b30f384b_6f6d_53ba_7d28_7911c9ff4fca["checkWeight()"]
  89cb31aa_5261_3d6d_adae_891147154070 -->|calls| b30f384b_6f6d_53ba_7d28_7911c9ff4fca
  style 89cb31aa_5261_3d6d_adae_891147154070 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/astro/src/assets/fonts/core/filter-preloads.ts lines 3–36

export function filterPreloads(
	data: Array<PreloadData>,
	preload: PreloadFilter,
): Array<PreloadData> | null {
	if (!preload) {
		return null;
	}
	if (preload === true) {
		// Preload everything
		return data;
	}
	// Only preload urls based on weight, style and subset
	return data.filter(({ weight, style, subset }) =>
		preload.some((p) => {
			// Always check the weight
			if (
				p.weight !== undefined &&
				weight !== undefined &&
				!checkWeight(p.weight.toString(), weight)
			) {
				return false;
			}
			// Only check the style if specified
			if (p.style !== undefined && p.style !== style) {
				return false;
			}
			// Only check the subset if specified
			if (p.subset !== undefined && p.subset !== subset) {
				return false;
			}
			return true;
		}),
	);
}

Domain

Subdomains

Frequently Asked Questions

What does filterPreloads() do?
filterPreloads() is a function in the astro codebase, defined in packages/astro/src/assets/fonts/core/filter-preloads.ts.
Where is filterPreloads() defined?
filterPreloads() is defined in packages/astro/src/assets/fonts/core/filter-preloads.ts at line 3.
What does filterPreloads() call?
filterPreloads() calls 1 function(s): checkWeight.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free