Home / Function/ AwaitBlock() — svelte Function Reference

AwaitBlock() — svelte Function Reference

Architecture documentation for the AwaitBlock() function in AwaitBlock.js from the svelte codebase.

Entity Profile

Dependency Diagram

graph TD
  40a9868f_fb12_2d7c_aa35_be01988cecf1["AwaitBlock()"]
  93e88a6f_3f11_4770_b83f_853f9bf1fc2b["AwaitBlock.js"]
  40a9868f_fb12_2d7c_aa35_be01988cecf1 -->|defined in| 93e88a6f_3f11_4770_b83f_853f9bf1fc2b
  ea08cb05_2664_4e93_7551_6103e0cb3a87["validate_block_not_empty()"]
  40a9868f_fb12_2d7c_aa35_be01988cecf1 -->|calls| ea08cb05_2664_4e93_7551_6103e0cb3a87
  7148e639_69d8_a03d_3f08_bd23f41e718a["validate_opening_tag()"]
  40a9868f_fb12_2d7c_aa35_be01988cecf1 -->|calls| 7148e639_69d8_a03d_3f08_bd23f41e718a
  433ea7d7_7b51_9dd7_908c_e2d48152abe1["block_unexpected_character()"]
  40a9868f_fb12_2d7c_aa35_be01988cecf1 -->|calls| 433ea7d7_7b51_9dd7_908c_e2d48152abe1
  313d2a82_30ea_3161_3aad_0cc2094979aa["mark_subtree_dynamic()"]
  40a9868f_fb12_2d7c_aa35_be01988cecf1 -->|calls| 313d2a82_30ea_3161_3aad_0cc2094979aa
  style 40a9868f_fb12_2d7c_aa35_be01988cecf1 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/svelte/src/compiler/phases/2-analyze/visitors/AwaitBlock.js lines 11–48

export function AwaitBlock(node, context) {
	validate_block_not_empty(node.pending, context);
	validate_block_not_empty(node.then, context);
	validate_block_not_empty(node.catch, context);

	if (context.state.analysis.runes) {
		validate_opening_tag(node, context.state, '#');

		if (node.value) {
			const start = /** @type {number} */ (node.value.start);
			const match = context.state.analysis.source
				.substring(start - 10, start)
				.match(/{(\s*):then\s+$/);

			if (match && match[1] !== '') {
				e.block_unexpected_character({ start: start - 10, end: start }, ':');
			}
		}

		if (node.error) {
			const start = /** @type {number} */ (node.error.start);
			const match = context.state.analysis.source
				.substring(start - 10, start)
				.match(/{(\s*):catch\s+$/);

			if (match && match[1] !== '') {
				e.block_unexpected_character({ start: start - 10, end: start }, ':');
			}
		}
	}

	mark_subtree_dynamic(context.path);

	context.visit(node.expression, { ...context.state, expression: node.metadata.expression });
	if (node.pending) context.visit(node.pending);
	if (node.then) context.visit(node.then);
	if (node.catch) context.visit(node.catch);
}

Domain

Subdomains

Frequently Asked Questions

What does AwaitBlock() do?
AwaitBlock() is a function in the svelte codebase, defined in packages/svelte/src/compiler/phases/2-analyze/visitors/AwaitBlock.js.
Where is AwaitBlock() defined?
AwaitBlock() is defined in packages/svelte/src/compiler/phases/2-analyze/visitors/AwaitBlock.js at line 11.
What does AwaitBlock() call?
AwaitBlock() calls 4 function(s): block_unexpected_character, mark_subtree_dynamic, validate_block_not_empty, validate_opening_tag.

Analyze Your Own Codebase

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

Try Supermodel Free