concat() — svelte Function Reference
Architecture documentation for the concat() function in mapped_code.js from the svelte codebase.
Entity Profile
Dependency Diagram
graph TD 0b0d6cc0_5fd9_5ba4_3426_05a4a4d6e501["concat()"] fd3be7c7_b876_965d_9025_a9b9bd4c6aaf["MappedCode"] 0b0d6cc0_5fd9_5ba4_3426_05a4a4d6e501 -->|defined in| fd3be7c7_b876_965d_9025_a9b9bd4c6aaf 860c55db_f911_8bca_7055_338865a9f9b0["processed_tag_to_code()"] 860c55db_f911_8bca_7055_338865a9f9b0 -->|calls| 0b0d6cc0_5fd9_5ba4_3426_05a4a4d6e501 248beedc_da17_46c9_c5b6_5da6d39a6912["perform_replacements()"] 248beedc_da17_46c9_c5b6_5da6d39a6912 -->|calls| 0b0d6cc0_5fd9_5ba4_3426_05a4a4d6e501 83e8a17c_7a83_f4d3_1629_6a92427d44f2["get_relative_path()"] 83e8a17c_7a83_f4d3_1629_6a92427d44f2 -->|calls| 0b0d6cc0_5fd9_5ba4_3426_05a4a4d6e501 12c5ce18_efc3_f2cd_b20e_c2c5a3b93456["last_line_length()"] 0b0d6cc0_5fd9_5ba4_3426_05a4a4d6e501 -->|calls| 12c5ce18_efc3_f2cd_b20e_c2c5a3b93456 9db1b33e_4e31_18be_5caa_623f777ec65d["merge_tables()"] 0b0d6cc0_5fd9_5ba4_3426_05a4a4d6e501 -->|calls| 9db1b33e_4e31_18be_5caa_623f777ec65d 6604fbb1_f99a_248a_dfc6_b9e14a5f0a36["push_array()"] 0b0d6cc0_5fd9_5ba4_3426_05a4a4d6e501 -->|calls| 6604fbb1_f99a_248a_dfc6_b9e14a5f0a36 style 0b0d6cc0_5fd9_5ba4_3426_05a4a4d6e501 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/svelte/src/compiler/utils/mapped_code.js lines 109–184
concat(other) {
// noop: if one is empty, return the other
if (other.string == '') return this;
if (this.string == '') {
this.string = other.string;
this.map = other.map;
return this;
}
// compute last line length before mutating
const column_offset = last_line_length(this.string);
this.string += other.string;
const m1 = this.map;
const m2 = other.map;
if (m2.mappings.length == 0) return this;
// combine sources and names
const [sources, new_source_idx, sources_changed, sources_idx_changed] = merge_tables(
m1.sources,
m2.sources
);
const [names, new_name_idx, names_changed, names_idx_changed] = merge_tables(
m1.names,
m2.names
);
if (sources_changed) m1.sources = sources;
if (names_changed) m1.names = names;
// unswitched loops are faster
if (sources_idx_changed && names_idx_changed) {
for (let line = 0; line < m2.mappings.length; line++) {
const segment_list = m2.mappings[line];
for (let segment = 0; segment < segment_list.length; segment++) {
const seg = segment_list[segment];
// @ts-ignore
if (seg[1] >= 0) seg[1] = new_source_idx[seg[1]];
// @ts-ignore
if (seg[4] >= 0) seg[4] = new_name_idx[seg[4]];
}
}
} else if (sources_idx_changed) {
for (let line = 0; line < m2.mappings.length; line++) {
const segment_list = m2.mappings[line];
for (let segment = 0; segment < segment_list.length; segment++) {
const seg = segment_list[segment];
// @ts-ignore
if (seg[1] >= 0) seg[1] = new_source_idx[seg[1]];
}
}
} else if (names_idx_changed) {
for (let line = 0; line < m2.mappings.length; line++) {
const segment_list = m2.mappings[line];
for (let segment = 0; segment < segment_list.length; segment++) {
const seg = segment_list[segment];
// @ts-ignore
if (seg[4] >= 0) seg[4] = new_name_idx[seg[4]];
}
}
}
// combine the mappings
// combine
// 1. last line of first map
// 2. first line of second map
// columns of 2 must be shifted
if (m2.mappings.length > 0 && column_offset > 0) {
const first_line = m2.mappings[0];
for (let i = 0; i < first_line.length; i++) {
first_line[i][0] += column_offset;
}
}
// combine last line + first line
push_array(
m1.mappings[m1.mappings.length - 1],
/** @type {SourceMapSegment[]} */ (m2.mappings.shift())
);
// append other lines
push_array(m1.mappings, m2.mappings);
return this;
}
Domain
Subdomains
Source
Frequently Asked Questions
What does concat() do?
concat() is a function in the svelte codebase, defined in packages/svelte/src/compiler/utils/mapped_code.js.
Where is concat() defined?
concat() is defined in packages/svelte/src/compiler/utils/mapped_code.js at line 109.
What does concat() call?
concat() calls 3 function(s): last_line_length, merge_tables, push_array.
What calls concat()?
concat() is called by 3 function(s): get_relative_path, perform_replacements, processed_tag_to_code.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free