MCPcopy
hub / github.com/sveltejs/svelte / compare

Function compare

packages/svelte/src/internal/server/hydratable.js:109–132  ·  view source on GitHub ↗

* @param {string} key * @param {HydratableLookupEntry} a * @param {HydratableLookupEntry} b

(key, a, b)

Source from the content-addressed store, hash-verified

107 * @param {HydratableLookupEntry} b
108 */
109async function compare(key, a, b) {
110 // note: these need to be loops (as opposed to Promise.all) because
111 // additional promises can get pushed to them while we're awaiting
112 // an earlier one
113 for (const p of a?.promises ?? []) {
114 await p;
115 }
116
117 for (const p of b?.promises ?? []) {
118 await p;
119 }
120
121 if (a.serialized !== b.serialized) {
122 const a_stack = /** @type {string} */ (a.stack);
123 const b_stack = /** @type {string} */ (b.stack);
124
125 const stack =
126 a_stack === b_stack
127 ? `Occurred at:\n${a_stack}`
128 : `First occurrence at:\n${a_stack}\n\nSecond occurrence at:\n${b_stack}`;
129
130 e.hydratable_clobbering(key, stack);
131 }
132}
133
134/**
135 * @param {string | undefined} root_stack

Callers 1

hydratableFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected