Home / Function/ unwrap_pattern() — svelte Function Reference

unwrap_pattern() — svelte Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  d935f45f_6959_e32d_6e74_07f0885da3b7["unwrap_pattern()"]
  0c5c28a7_226d_4e7c_e75e_0853c0a9fc2c["ast.js"]
  d935f45f_6959_e32d_6e74_07f0885da3b7 -->|defined in| 0c5c28a7_226d_4e7c_e75e_0853c0a9fc2c
  aced5321_4478_4f67_ba8c_e122713c1d9f["calculate_blockers()"]
  aced5321_4478_4f67_ba8c_e122713c1d9f -->|calls| d935f45f_6959_e32d_6e74_07f0885da3b7
  c531899f_2ddc_b054_bfe1_2cfdfd2b1c7f["create_scopes()"]
  c531899f_2ddc_b054_bfe1_2cfdfd2b1c7f -->|calls| d935f45f_6959_e32d_6e74_07f0885da3b7
  c12e0147_3f27_cf17_5878_e54ffdc328d5["extract_identifiers()"]
  c12e0147_3f27_cf17_5878_e54ffdc328d5 -->|calls| d935f45f_6959_e32d_6e74_07f0885da3b7
  style d935f45f_6959_e32d_6e74_07f0885da3b7 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/svelte/src/compiler/utils/ast.js lines 89–129

export function unwrap_pattern(pattern, nodes = []) {
	switch (pattern.type) {
		case 'Identifier':
			nodes.push(pattern);
			break;

		case 'MemberExpression':
			// member expressions can be part of an assignment pattern, but not a binding pattern
			// see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment#binding_and_assignment
			nodes.push(pattern);
			break;

		case 'ObjectPattern':
			for (const prop of pattern.properties) {
				if (prop.type === 'RestElement') {
					unwrap_pattern(prop.argument, nodes);
				} else {
					unwrap_pattern(prop.value, nodes);
				}
			}

			break;

		case 'ArrayPattern':
			for (const element of pattern.elements) {
				if (element) unwrap_pattern(element, nodes);
			}

			break;

		case 'RestElement':
			unwrap_pattern(pattern.argument, nodes);
			break;

		case 'AssignmentPattern':
			unwrap_pattern(pattern.left, nodes);
			break;
	}

	return nodes;
}

Domain

Subdomains

Frequently Asked Questions

What does unwrap_pattern() do?
unwrap_pattern() is a function in the svelte codebase, defined in packages/svelte/src/compiler/utils/ast.js.
Where is unwrap_pattern() defined?
unwrap_pattern() is defined in packages/svelte/src/compiler/utils/ast.js at line 89.
What calls unwrap_pattern()?
unwrap_pattern() is called by 3 function(s): calculate_blockers, create_scopes, extract_identifiers.

Analyze Your Own Codebase

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

Try Supermodel Free