init_array_prototype_warnings() — svelte Function Reference
Architecture documentation for the init_array_prototype_warnings() function in equality.js from the svelte codebase.
Entity Profile
Dependency Diagram
graph TD ff98bd09_e6fd_2deb_9709_503ac689db35["init_array_prototype_warnings()"] 9fcf2863_565e_f328_30b3_46748f0e7489["equality.js"] ff98bd09_e6fd_2deb_9709_503ac689db35 -->|defined in| 9fcf2863_565e_f328_30b3_46748f0e7489 a413fb77_0391_6be3_509e_911e3ab4e488["init_operations()"] a413fb77_0391_6be3_509e_911e3ab4e488 -->|calls| ff98bd09_e6fd_2deb_9709_503ac689db35 26dfb8f0_9124_b0f3_036d_7fac50a771b5["get_proxied_value()"] ff98bd09_e6fd_2deb_9709_503ac689db35 -->|calls| 26dfb8f0_9124_b0f3_036d_7fac50a771b5 865ba1fe_25fd_bfa2_437d_30eb2bda2a9a["state_proxy_equality_mismatch()"] ff98bd09_e6fd_2deb_9709_503ac689db35 -->|calls| 865ba1fe_25fd_bfa2_437d_30eb2bda2a9a style ff98bd09_e6fd_2deb_9709_503ac689db35 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/svelte/src/internal/client/dev/equality.js lines 4–69
export function init_array_prototype_warnings() {
const array_prototype = Array.prototype;
// The REPL ends up here over and over, and this prevents it from adding more and more patches
// of the same kind to the prototype, which would slow down everything over time.
// @ts-expect-error
const cleanup = Array.__svelte_cleanup;
if (cleanup) {
cleanup();
}
const { indexOf, lastIndexOf, includes } = array_prototype;
array_prototype.indexOf = function (item, from_index) {
const index = indexOf.call(this, item, from_index);
if (index === -1) {
for (let i = from_index ?? 0; i < this.length; i += 1) {
if (get_proxied_value(this[i]) === item) {
w.state_proxy_equality_mismatch('array.indexOf(...)');
break;
}
}
}
return index;
};
array_prototype.lastIndexOf = function (item, from_index) {
// we need to specify this.length - 1 because it's probably using something like
// `arguments` inside so passing undefined is different from not passing anything
const index = lastIndexOf.call(this, item, from_index ?? this.length - 1);
if (index === -1) {
for (let i = 0; i <= (from_index ?? this.length - 1); i += 1) {
if (get_proxied_value(this[i]) === item) {
w.state_proxy_equality_mismatch('array.lastIndexOf(...)');
break;
}
}
}
return index;
};
array_prototype.includes = function (item, from_index) {
const has = includes.call(this, item, from_index);
if (!has) {
for (let i = 0; i < this.length; i += 1) {
if (get_proxied_value(this[i]) === item) {
w.state_proxy_equality_mismatch('array.includes(...)');
break;
}
}
}
return has;
};
// @ts-expect-error
Array.__svelte_cleanup = () => {
array_prototype.indexOf = indexOf;
array_prototype.lastIndexOf = lastIndexOf;
array_prototype.includes = includes;
};
}
Domain
Subdomains
Called By
Source
Frequently Asked Questions
What does init_array_prototype_warnings() do?
init_array_prototype_warnings() is a function in the svelte codebase, defined in packages/svelte/src/internal/client/dev/equality.js.
Where is init_array_prototype_warnings() defined?
init_array_prototype_warnings() is defined in packages/svelte/src/internal/client/dev/equality.js at line 4.
What does init_array_prototype_warnings() call?
init_array_prototype_warnings() calls 2 function(s): get_proxied_value, state_proxy_equality_mismatch.
What calls init_array_prototype_warnings()?
init_array_prototype_warnings() is called by 1 function(s): init_operations.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free