unthunk() — svelte Function Reference
Architecture documentation for the unthunk() function in builders.js from the svelte codebase.
Entity Profile
Dependency Diagram
graph TD 48afe7ab_bb6e_7895_aca1_6433240d18a3["unthunk()"] 18e3101f_3e97_34c3_7373_b587af4b78e1["builders.js"] 48afe7ab_bb6e_7895_aca1_6433240d18a3 -->|defined in| 18e3101f_3e97_34c3_7373_b587af4b78e1 ee6da0da_a970_1fca_7676_8193019eb85e["thunk()"] ee6da0da_a970_1fca_7676_8193019eb85e -->|calls| 48afe7ab_bb6e_7895_aca1_6433240d18a3 c5b1e5e6_49b7_ac9e_9572_7d6c11e99bc7["has_await_expression()"] 48afe7ab_bb6e_7895_aca1_6433240d18a3 -->|calls| c5b1e5e6_49b7_ac9e_9572_7d6c11e99bc7 1fb6b372_75e6_ebba_568e_828733e93221["arrow()"] 48afe7ab_bb6e_7895_aca1_6433240d18a3 -->|calls| 1fb6b372_75e6_ebba_568e_828733e93221 style 48afe7ab_bb6e_7895_aca1_6433240d18a3 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/svelte/src/compiler/utils/builders.js lines 464–485
export function unthunk(expression) {
// optimize `async () => await x()`, but not `async () => await x(await y)`
if (expression.async && expression.body.type === 'AwaitExpression') {
if (!has_await_expression(expression.body.argument)) {
return unthunk(arrow(expression.params, expression.body.argument));
}
}
if (
expression.async === false &&
expression.body.type === 'CallExpression' &&
expression.body.callee.type === 'Identifier' &&
expression.params.length === expression.body.arguments.length &&
expression.params.every((param, index) => {
const arg = /** @type {ESTree.SimpleCallExpression} */ (expression.body).arguments[index];
return param.type === 'Identifier' && arg.type === 'Identifier' && param.name === arg.name;
})
) {
return expression.body.callee;
}
return expression;
}
Domain
Subdomains
Called By
Source
Frequently Asked Questions
What does unthunk() do?
unthunk() is a function in the svelte codebase, defined in packages/svelte/src/compiler/utils/builders.js.
Where is unthunk() defined?
unthunk() is defined in packages/svelte/src/compiler/utils/builders.js at line 464.
What does unthunk() call?
unthunk() calls 2 function(s): arrow, has_await_expression.
What calls unthunk()?
unthunk() is called by 1 function(s): thunk.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free