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

Function set

packages/svelte/src/store/shared/index.js:45–63  ·  view source on GitHub ↗

* @param {T} new_value * @returns {void}

(new_value)

Source from the content-addressed store, hash-verified

43 * @returns {void}
44 */
45 function set(new_value) {
46 if (safe_not_equal(value, new_value)) {
47 value = new_value;
48 if (stop) {
49 // store is ready
50 const run_queue = !subscriber_queue.length;
51 for (const subscriber of subscribers) {
52 subscriber[1]();
53 subscriber_queue.push(subscriber, value);
54 }
55 if (run_queue) {
56 for (let i = 0; i < subscriber_queue.length; i += 2) {
57 subscriber_queue[i][0](subscriber_queue[i + 1]);
58 }
59 subscriber_queue.length = 0;
60 }
61 }
62 }
63 }
64
65 /**
66 * @param {Updater<T>} fn

Callers 4

updateFunction · 0.70
syncFunction · 0.70
toStoreFunction · 0.50
toStoreFunction · 0.50

Calls 2

safe_not_equalFunction · 0.90
pushMethod · 0.80

Tested by

no test coverage detected