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

Function set

packages/svelte/src/internal/client/reactivity/sources.js:152–172  ·  packages/svelte/src/internal/client/reactivity/sources.js::set
(source, value, should_proxy = false)

Source from the content-addressed store, hash-verified

150 * @returns {V}
151 */
152export function set(source, value, should_proxy = false) {
153 if (
154 active_reaction !== null &&
155 class="cm">// since we are untracking the function inside `$inspect.with` we need to add this check
156 class="cm">// to ensure we error if state is set inside an inspect effect
157 (!untracking || (active_reaction.f & EAGER_EFFECT) !== 0) &&
158 is_runes() &&
159 (active_reaction.f & (DERIVED | BLOCK_EFFECT | ASYNC | EAGER_EFFECT)) !== 0 &&
160 (current_sources === null || !current_sources.has(source))
161 ) {
162 e.state_unsafe_mutation();
163 }
164
165 let new_value = should_proxy ? proxy(value) : value;
166
167 if (DEV) {
168 tag_proxy(new_value, /** @type {string} */ (source.label));
169 }
170
171 return internal_set(source, new_value, legacy_updates);
172}
173
174/**
175 * @template V

Callers 7

test.tsFile · 0.90
test.tsFile · 0.90
vMethod · 0.90
mutateFunction · 0.70
updateFunction · 0.70
update_preFunction · 0.70
incrementFunction · 0.70

Calls 5

is_runesFunction · 0.90
proxyFunction · 0.90
tag_proxyFunction · 0.90
internal_setFunction · 0.85
hasMethod · 0.45

Tested by

no test coverage detected