_extract_paths() — svelte Function Reference
Architecture documentation for the _extract_paths() function in ast.js from the svelte codebase.
Entity Profile
Dependency Diagram
graph TD 27987cb0_7747_fd10_c20f_fd6c1f1c37e2["_extract_paths()"] 0c5c28a7_226d_4e7c_e75e_0853c0a9fc2c["ast.js"] 27987cb0_7747_fd10_c20f_fd6c1f1c37e2 -->|defined in| 0c5c28a7_226d_4e7c_e75e_0853c0a9fc2c c254e734_2224_c309_f1f8_bb064e80b1af["extract_paths()"] c254e734_2224_c309_f1f8_bb064e80b1af -->|calls| 27987cb0_7747_fd10_c20f_fd6c1f1c37e2 84572b9b_9a21_09af_15ac_85b59b114603["build_fallback()"] 27987cb0_7747_fd10_c20f_fd6c1f1c37e2 -->|calls| 84572b9b_9a21_09af_15ac_85b59b114603 style 27987cb0_7747_fd10_c20f_fd6c1f1c37e2 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/svelte/src/compiler/utils/ast.js lines 269–415
function _extract_paths(paths, inserts, param, expression, update_expression, has_default_value) {
switch (param.type) {
case 'Identifier':
case 'MemberExpression':
paths.push({
node: param,
is_rest: false,
has_default_value,
expression,
update_expression
});
break;
case 'ObjectPattern':
for (const prop of param.properties) {
if (prop.type === 'RestElement') {
/** @type {ESTree.Expression[]} */
const props = [];
for (const p of param.properties) {
if (p.type === 'Property' && p.key.type !== 'PrivateIdentifier') {
if (p.key.type === 'Identifier' && !p.computed) {
props.push(b.literal(p.key.name));
} else if (p.key.type === 'Literal') {
props.push(b.literal(String(p.key.value)));
} else {
props.push(b.call('String', p.key));
}
}
}
const rest_expression = b.call('$.exclude_from_object', expression, b.array(props));
if (prop.argument.type === 'Identifier') {
paths.push({
node: prop.argument,
is_rest: true,
has_default_value,
expression: rest_expression,
update_expression: rest_expression
});
} else {
_extract_paths(
paths,
inserts,
prop.argument,
rest_expression,
rest_expression,
has_default_value
);
}
} else {
const object_expression = b.member(
expression,
prop.key,
prop.computed || prop.key.type !== 'Identifier'
);
_extract_paths(
paths,
inserts,
prop.value,
object_expression,
object_expression,
has_default_value
);
}
}
break;
case 'ArrayPattern': {
// we create an intermediate declaration to convert iterables to arrays if necessary.
// the consumer is responsible for setting the name of the identifier
const id = b.id('#');
const value = b.call(
'$.to_array',
expression,
param.elements.at(-1)?.type === 'RestElement' ? undefined : b.literal(param.elements.length)
);
Domain
Subdomains
Defined In
Calls
Called By
Source
Frequently Asked Questions
What does _extract_paths() do?
_extract_paths() is a function in the svelte codebase, defined in packages/svelte/src/compiler/utils/ast.js.
Where is _extract_paths() defined?
_extract_paths() is defined in packages/svelte/src/compiler/utils/ast.js at line 269.
What does _extract_paths() call?
_extract_paths() calls 1 function(s): build_fallback.
What calls _extract_paths()?
_extract_paths() is called by 1 function(s): extract_paths.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free