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

Function inspectable_array

packages/svelte/src/internal/client/proxy.js:412–432  ·  view source on GitHub ↗

* Wrap array mutating methods so $inspect is triggered only once and * to prevent logging an array in intermediate state (e.g. with an empty slot) * @param {any[]} array

(array)

Source from the content-addressed store, hash-verified

410 * @param {any[]} array
411 */
412function inspectable_array(array) {
413 return new Proxy(array, {
414 get(target, prop, receiver) {
415 var value = Reflect.get(target, prop, receiver);
416 if (!ARRAY_MUTATING_METHODS.has(/** @type {string} */ (prop))) {
417 return value;
418 }
419
420 /**
421 * @this {any[]}
422 * @param {any[]} args
423 */
424 return function (...args) {
425 set_eager_effects_deferred();
426 var result = value.apply(this, args);
427 flush_eager_effects();
428 return result;
429 };
430 }
431 });
432}

Callers 1

proxyFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected