Home / File/ utils.js — svelte Source File

utils.js — svelte Source File

Architecture documentation for utils.js, a javascript file in the svelte codebase. 0 imports, 32 dependents.

File javascript SharedInternal DOMUtils 32 dependents 18 functions

Entity Profile

Dependency Diagram

graph LR
  2aa63f4e_82c9_33e3_ac6c_5f3d46250522["utils.js"]
  cab41022_1b55_3b7a_06c6_b90763bbea47["index.js"]
  cab41022_1b55_3b7a_06c6_b90763bbea47 --> 2aa63f4e_82c9_33e3_ac6c_5f3d46250522
  67d7170b_725b_33cc_868d_fad6ed435252["index.js"]
  67d7170b_725b_33cc_868d_fad6ed435252 --> 2aa63f4e_82c9_33e3_ac6c_5f3d46250522
  206889ff_1f9f_b6c1_d530_059d001e1cf4["element.js"]
  206889ff_1f9f_b6c1_d530_059d001e1cf4 --> 2aa63f4e_82c9_33e3_ac6c_5f3d46250522
  4aa8a188_84d4_0274_ed83_cac0ab1d3572["index.js"]
  4aa8a188_84d4_0274_ed83_cac0ab1d3572 --> 2aa63f4e_82c9_33e3_ac6c_5f3d46250522
  28ec60f4_a82f_1f06_ded7_1786b05aa1c0["Attribute.js"]
  28ec60f4_a82f_1f06_ded7_1786b05aa1c0 --> 2aa63f4e_82c9_33e3_ac6c_5f3d46250522
  6b8c189e_23e1_77d3_9ee3_3eec5012a9b2["BindDirective.js"]
  6b8c189e_23e1_77d3_9ee3_3eec5012a9b2 --> 2aa63f4e_82c9_33e3_ac6c_5f3d46250522
  ae63a5f8_3bca_b89d_d2cc_a72104d95a3b["ClassBody.js"]
  ae63a5f8_3bca_b89d_d2cc_a72104d95a3b --> 2aa63f4e_82c9_33e3_ac6c_5f3d46250522
  dbcd64ee_7333_aa92_9b8e_ed189c6c4449["Identifier.js"]
  dbcd64ee_7333_aa92_9b8e_ed189c6c4449 --> 2aa63f4e_82c9_33e3_ac6c_5f3d46250522
  60af7ccf_2ceb_e5af_2432_c5b753a12c2a["RegularElement.js"]
  60af7ccf_2ceb_e5af_2432_c5b753a12c2a --> 2aa63f4e_82c9_33e3_ac6c_5f3d46250522
  b389a21f_6de7_2a41_34f3_8efbf9045c9c["index.js"]
  b389a21f_6de7_2a41_34f3_8efbf9045c9c --> 2aa63f4e_82c9_33e3_ac6c_5f3d46250522
  c3ec4c82_ce35_6219_c232_12ebeea91443["template.js"]
  c3ec4c82_ce35_6219_c232_12ebeea91443 --> 2aa63f4e_82c9_33e3_ac6c_5f3d46250522
  4610488f_3cf2_5f73_043e_da0aa9d026fe["RegularElement.js"]
  4610488f_3cf2_5f73_043e_da0aa9d026fe --> 2aa63f4e_82c9_33e3_ac6c_5f3d46250522
  96059f46_734f_8649_48af_e9bf0906b175["SvelteHead.js"]
  96059f46_734f_8649_48af_e9bf0906b175 --> 2aa63f4e_82c9_33e3_ac6c_5f3d46250522
  7880f852_1b7b_9ea3_4e22_732f4a684bbe["element.js"]
  7880f852_1b7b_9ea3_4e22_732f4a684bbe --> 2aa63f4e_82c9_33e3_ac6c_5f3d46250522
  style 2aa63f4e_82c9_33e3_ac6c_5f3d46250522 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

const regex_return_characters = /\r/g;

/**
 * @param {string} str
 * @returns {string}
 */
export function hash(str) {
	str = str.replace(regex_return_characters, '');
	let hash = 5381;
	let i = str.length;

	while (i--) hash = ((hash << 5) - hash) ^ str.charCodeAt(i);
	return (hash >>> 0).toString(36);
}

const VOID_ELEMENT_NAMES = [
	'area',
	'base',
	'br',
	'col',
	'command',
	'embed',
	'hr',
	'img',
	'input',
	'keygen',
	'link',
	'meta',
	'param',
	'source',
	'track',
	'wbr'
];

/**
 * Returns `true` if `name` is of a void element
 * @param {string} name
 */
export function is_void(name) {
	return VOID_ELEMENT_NAMES.includes(name) || name.toLowerCase() === '!doctype';
}

const RESERVED_WORDS = [
	'arguments',
	'await',
	'break',
	'case',
	'catch',
	'class',
	'const',
	'continue',
	'debugger',
	'default',
	'delete',
	'do',
	'else',
	'enum',
	'eval',
	'export',
	'extends',
// ... (432 more lines)

Subdomains

Imported By

Frequently Asked Questions

What does utils.js do?
utils.js is a source file in the svelte codebase, written in javascript. It belongs to the SharedInternal domain, DOMUtils subdomain.
What functions are defined in utils.js?
utils.js defines 18 function(s): can_delegate_event, cannot_be_set_statically, hash, is_boolean_attribute, is_capture_event, is_content_editable_binding, is_dom_property, is_load_error_element, is_mathml, is_passive_event, and 8 more.
What files import utils.js?
utils.js is imported by 32 file(s): Attribute.js, BindDirective.js, ClassBody.js, Identifier.js, RegularElement.js, RegularElement.js, RegularElement.js, SvelteHead.js, and 24 more.
Where is utils.js in the architecture?
utils.js is located at packages/svelte/src/utils.js (domain: SharedInternal, subdomain: DOMUtils, directory: packages/svelte/src).

Analyze Your Own Codebase

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

Try Supermodel Free