Home / Function/ should_proxy() — svelte Function Reference

should_proxy() — svelte Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  88db3726_5740_3eb8_99fb_4b297fb19b24["should_proxy()"]
  c518b20b_2355_7b11_4ac2_2d9bb5dcfb43["utils.js"]
  88db3726_5740_3eb8_99fb_4b297fb19b24 -->|defined in| c518b20b_2355_7b11_4ac2_2d9bb5dcfb43
  5c01291d_15ff_bab3_2463_d54766affbf6["Identifier()"]
  5c01291d_15ff_bab3_2463_d54766affbf6 -->|calls| 88db3726_5740_3eb8_99fb_4b297fb19b24
  de76709c_7ae0_7ba1_eecf_1f23ef572fb0["build_assignment()"]
  de76709c_7ae0_7ba1_eecf_1f23ef572fb0 -->|calls| 88db3726_5740_3eb8_99fb_4b297fb19b24
  633f2cfa_9e09_691b_a265_c937cdee3900["CallExpression()"]
  633f2cfa_9e09_691b_a265_c937cdee3900 -->|calls| 88db3726_5740_3eb8_99fb_4b297fb19b24
  dbadea0c_9bb0_dd96_41bd_09a33169352f["VariableDeclaration()"]
  dbadea0c_9bb0_dd96_41bd_09a33169352f -->|calls| 88db3726_5740_3eb8_99fb_4b297fb19b24
  style 88db3726_5740_3eb8_99fb_4b297fb19b24 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/svelte/src/compiler/phases/3-transform/client/utils.js lines 133–165

export function should_proxy(node, scope) {
	if (
		!node ||
		node.type === 'Literal' ||
		node.type === 'TemplateLiteral' ||
		node.type === 'ArrowFunctionExpression' ||
		node.type === 'FunctionExpression' ||
		node.type === 'UnaryExpression' ||
		node.type === 'BinaryExpression' ||
		(node.type === 'Identifier' && node.name === 'undefined')
	) {
		return false;
	}

	if (node.type === 'Identifier' && scope !== null) {
		const binding = scope.get(node.name);
		// Let's see if the reference is something that can be proxied
		if (
			binding !== null &&
			!binding.reassigned &&
			binding.initial !== null &&
			binding.initial.type !== 'FunctionDeclaration' &&
			binding.initial.type !== 'ClassDeclaration' &&
			binding.initial.type !== 'ImportDeclaration' &&
			binding.initial.type !== 'EachBlock' &&
			binding.initial.type !== 'SnippetBlock'
		) {
			return should_proxy(binding.initial, null);
		}
	}

	return true;
}

Domain

Subdomains

Frequently Asked Questions

What does should_proxy() do?
should_proxy() is a function in the svelte codebase, defined in packages/svelte/src/compiler/phases/3-transform/client/utils.js.
Where is should_proxy() defined?
should_proxy() is defined in packages/svelte/src/compiler/phases/3-transform/client/utils.js at line 133.
What calls should_proxy()?
should_proxy() is called by 4 function(s): CallExpression, Identifier, VariableDeclaration, build_assignment.

Analyze Your Own Codebase

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

Try Supermodel Free