inspect() — svelte Function Reference
Architecture documentation for the inspect() function in inspect.js from the svelte codebase.
Entity Profile
Dependency Diagram
graph TD effdfef7_fe43_dc08_1914_518e8bf28c39["inspect()"] 2ee049d6_d6d3_ee9b_a2e1_010085c52b2c["inspect.js"] effdfef7_fe43_dc08_1914_518e8bf28c39 -->|defined in| 2ee049d6_d6d3_ee9b_a2e1_010085c52b2c b78cad2e_34cc_9fa8_80d7_78a1f69d3539["validate_effect()"] effdfef7_fe43_dc08_1914_518e8bf28c39 -->|calls| b78cad2e_34cc_9fa8_80d7_78a1f69d3539 80b95503_e5bc_4965_f8d9_a5ec40e8e1c2["eager_effect()"] effdfef7_fe43_dc08_1914_518e8bf28c39 -->|calls| 80b95503_e5bc_4965_f8d9_a5ec40e8e1c2 532a740d_d410_0fd6_983a_933cb13808e7["snapshot()"] effdfef7_fe43_dc08_1914_518e8bf28c39 -->|calls| 532a740d_d410_0fd6_983a_933cb13808e7 a814b193_e12a_4037_c3c8_dfd45f3bd0bb["untrack()"] effdfef7_fe43_dc08_1914_518e8bf28c39 -->|calls| a814b193_e12a_4037_c3c8_dfd45f3bd0bb cc46feba_170d_5970_a6be_f512f15aa0ee["get_error()"] effdfef7_fe43_dc08_1914_518e8bf28c39 -->|calls| cc46feba_170d_5970_a6be_f512f15aa0ee 7494b934_a3b8_689e_91b6_8435e26461c5["render_effect()"] effdfef7_fe43_dc08_1914_518e8bf28c39 -->|calls| 7494b934_a3b8_689e_91b6_8435e26461c5 style effdfef7_fe43_dc08_1914_518e8bf28c39 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/svelte/src/internal/client/dev/inspect.js lines 12–72
export function inspect(get_value, inspector, show_stack = false) {
validate_effect('$inspect');
let initial = true;
let error = /** @type {any} */ (UNINITIALIZED);
// Inspect effects runs synchronously so that we can capture useful
// stack traces. As a consequence, reading the value might result
// in an error (an `$inspect(object.property)` will run before the
// `{#if object}...{/if}` that contains it)
eager_effect(() => {
try {
var value = get_value();
} catch (e) {
error = e;
return;
}
var snap = snapshot(value, true, true);
untrack(() => {
if (show_stack) {
inspector(...snap);
if (!initial) {
const stack = get_error('$inspect(...)');
if (stack) {
// eslint-disable-next-line no-console
console.groupCollapsed('stack trace');
// eslint-disable-next-line no-console
console.log(stack);
// eslint-disable-next-line no-console
console.groupEnd();
}
}
} else {
inspector(initial ? 'init' : 'update', ...snap);
}
});
initial = false;
});
// If an error occurs, we store it (along with its stack trace).
// If the render effect subsequently runs, we log the error,
// but if it doesn't run it's because the `$inspect` was
// destroyed, meaning we don't need to bother
render_effect(() => {
try {
// call `get_value` so that this runs alongside the inspect effect
get_value();
} catch {
// ignore
}
if (error !== UNINITIALIZED) {
// eslint-disable-next-line no-console
console.error(error);
error = UNINITIALIZED;
}
});
}
Domain
Subdomains
Source
Frequently Asked Questions
What does inspect() do?
inspect() is a function in the svelte codebase, defined in packages/svelte/src/internal/client/dev/inspect.js.
Where is inspect() defined?
inspect() is defined in packages/svelte/src/internal/client/dev/inspect.js at line 12.
What does inspect() call?
inspect() calls 6 function(s): eager_effect, get_error, render_effect, snapshot, untrack, validate_effect.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free