(source, value, should_proxy = false)
| 150 | * @returns {V} |
| 151 | */ |
| 152 | export 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 |
no test coverage detected