Home / Function/ merge_tables() — svelte Function Reference

merge_tables() — svelte Function Reference

Architecture documentation for the merge_tables() function in mapped_code.js from the svelte codebase.

Entity Profile

Dependency Diagram

graph TD
  9db1b33e_4e31_18be_5caa_623f777ec65d["merge_tables()"]
  d383a41d_5383_ee86_cab6_03bf1a2daf93["mapped_code.js"]
  9db1b33e_4e31_18be_5caa_623f777ec65d -->|defined in| d383a41d_5383_ee86_cab6_03bf1a2daf93
  0b0d6cc0_5fd9_5ba4_3426_05a4a4d6e501["concat()"]
  0b0d6cc0_5fd9_5ba4_3426_05a4a4d6e501 -->|calls| 9db1b33e_4e31_18be_5caa_623f777ec65d
  style 9db1b33e_4e31_18be_5caa_623f777ec65d fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/svelte/src/compiler/utils/mapped_code.js lines 48–72

function merge_tables(this_table, other_table) {
	const new_table = this_table.slice();
	const idx_map = [];
	other_table = other_table || [];
	let val_changed = false;
	for (const [other_idx, other_val] of other_table.entries()) {
		const this_idx = this_table.indexOf(other_val);
		if (this_idx >= 0) {
			idx_map[other_idx] = this_idx;
		} else {
			const new_idx = new_table.length;
			new_table[new_idx] = other_val;
			idx_map[other_idx] = new_idx;
			val_changed = true;
		}
	}
	let idx_changed = val_changed;
	if (val_changed) {
		if (idx_map.find((val, idx) => val != idx) === undefined) {
			// idx_map is identity map [0, 1, 2, 3, 4, ....]
			idx_changed = false;
		}
	}
	return [new_table, idx_map, val_changed, idx_changed];
}

Domain

Subdomains

Called By

Frequently Asked Questions

What does merge_tables() do?
merge_tables() is a function in the svelte codebase, defined in packages/svelte/src/compiler/utils/mapped_code.js.
Where is merge_tables() defined?
merge_tables() is defined in packages/svelte/src/compiler/utils/mapped_code.js at line 48.
What calls merge_tables()?
merge_tables() is called by 1 function(s): concat.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free