Home / Function/ compare() — svelte Function Reference

compare() — svelte Function Reference

Architecture documentation for the compare() function in hydratable.js from the svelte codebase.

Entity Profile

Dependency Diagram

graph TD
  3af20123_9b35_859d_7355_a5f03f994226["compare()"]
  2d51c6c9_d3dc_2c19_12a2_18adb2ef1c08["hydratable.js"]
  3af20123_9b35_859d_7355_a5f03f994226 -->|defined in| 2d51c6c9_d3dc_2c19_12a2_18adb2ef1c08
  aceb9558_4599_fbdb_f0c7_8abf2fb32324["hydratable()"]
  aceb9558_4599_fbdb_f0c7_8abf2fb32324 -->|calls| 3af20123_9b35_859d_7355_a5f03f994226
  41d213cb_de04_3315_55b0_42e0fae96dfc["hydratable_clobbering()"]
  3af20123_9b35_859d_7355_a5f03f994226 -->|calls| 41d213cb_de04_3315_55b0_42e0fae96dfc
  style 3af20123_9b35_859d_7355_a5f03f994226 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/svelte/src/internal/server/hydratable.js lines 104–127

async function compare(key, a, b) {
	// note: these need to be loops (as opposed to Promise.all) because
	// additional promises can get pushed to them while we're awaiting
	// an earlier one
	for (const p of a?.promises ?? []) {
		await p;
	}

	for (const p of b?.promises ?? []) {
		await p;
	}

	if (a.serialized !== b.serialized) {
		const a_stack = /** @type {string} */ (a.stack);
		const b_stack = /** @type {string} */ (b.stack);

		const stack =
			a_stack === b_stack
				? `Occurred at:\n${a_stack}`
				: `First occurrence at:\n${a_stack}\n\nSecond occurrence at:\n${b_stack}`;

		e.hydratable_clobbering(key, stack);
	}
}

Domain

Subdomains

Called By

Frequently Asked Questions

What does compare() do?
compare() is a function in the svelte codebase, defined in packages/svelte/src/internal/server/hydratable.js.
Where is compare() defined?
compare() is defined in packages/svelte/src/internal/server/hydratable.js at line 104.
What does compare() call?
compare() calls 1 function(s): hydratable_clobbering.
What calls compare()?
compare() is called by 1 function(s): hydratable.

Analyze Your Own Codebase

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

Try Supermodel Free