bracket.js — svelte Source File
Architecture documentation for bracket.js, a javascript file in the svelte codebase. 2 imports, 3 dependents.
Entity Profile
Dependency Diagram
graph LR 0d221a90_b1cc_5826_235e_98f5216d6400["bracket.js"] 495501a4_a342_6a4d_ac11_e3e2fee8b218["errors.js"] 0d221a90_b1cc_5826_235e_98f5216d6400 --> 495501a4_a342_6a4d_ac11_e3e2fee8b218 a146f6ac_0088_8736_b6ce_318f9f115170["e"] 0d221a90_b1cc_5826_235e_98f5216d6400 --> a146f6ac_0088_8736_b6ce_318f9f115170 caefc1b2_dc4c_2cff_4013_e8ded13e7974["context.js"] caefc1b2_dc4c_2cff_4013_e8ded13e7974 --> 0d221a90_b1cc_5826_235e_98f5216d6400 8b705104_0cb9_c5c8_5bed_6dcfe73592d3["expression.js"] 8b705104_0cb9_c5c8_5bed_6dcfe73592d3 --> 0d221a90_b1cc_5826_235e_98f5216d6400 367a364a_2912_a1aa_b2e1_d97a82783c38["tag.js"] 367a364a_2912_a1aa_b2e1_d97a82783c38 --> 0d221a90_b1cc_5826_235e_98f5216d6400 style 0d221a90_b1cc_5826_235e_98f5216d6400 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
/** @import { Parser } from '../index.js' */
import * as e from '../../../errors.js';
/**
* @param {number} num
* @returns {number} Infinity if {@link num} is negative, else {@link num}.
*/
function infinity_if_negative(num) {
if (num < 0) {
return Infinity;
}
return num;
}
/**
* @param {string} string The string to search.
* @param {number} search_start_index The index to start searching at.
* @param {"'" | '"' | '`'} string_start_char The character that started this string.
* @returns {number} The index of the end of this string expression, or `Infinity` if not found.
*/
function find_string_end(string, search_start_index, string_start_char) {
let string_to_search;
if (string_start_char === '`') {
string_to_search = string;
} else {
// we could slice at the search start index, but this way the index remains valid
string_to_search = string.slice(
0,
infinity_if_negative(string.indexOf('\n', search_start_index))
);
}
return find_unescaped_char(string_to_search, search_start_index, string_start_char);
}
/**
* @param {string} string The string to search.
* @param {number} search_start_index The index to start searching at.
* @returns {number} The index of the end of this regex expression, or `Infinity` if not found.
*/
function find_regex_end(string, search_start_index) {
return find_unescaped_char(string, search_start_index, '/');
}
/**
*
* @param {string} string The string to search.
* @param {number} search_start_index The index to begin the search at.
* @param {string} char The character to search for.
* @returns {number} The index of the first unescaped instance of {@link char}, or `Infinity` if not found.
*/
function find_unescaped_char(string, search_start_index, char) {
let i = search_start_index;
while (true) {
const found_index = string.indexOf(char, i);
if (found_index === -1) {
return Infinity;
}
if (count_leading_backslashes(string, found_index - 1) % 2 === 0) {
return found_index;
// ... (154 more lines)
Domain
Subdomains
Functions
Imported By
Source
Frequently Asked Questions
What does bracket.js do?
bracket.js is a source file in the svelte codebase, written in javascript. It belongs to the Compiler domain, Transformer subdomain.
What functions are defined in bracket.js?
bracket.js defines 8 function(s): count_leading_backslashes, find_matching_bracket, find_regex_end, find_string_end, find_unescaped_char, infinity_if_negative, match_bracket, match_quote.
What does bracket.js depend on?
bracket.js imports 2 module(s): e, errors.js.
What files import bracket.js?
bracket.js is imported by 3 file(s): context.js, expression.js, tag.js.
Where is bracket.js in the architecture?
bracket.js is located at packages/svelte/src/compiler/phases/1-parse/utils/bracket.js (domain: Compiler, subdomain: Transformer, directory: packages/svelte/src/compiler/phases/1-parse/utils).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free