Home / Function/ list() — svelte Function Reference

list() — svelte Function Reference

Architecture documentation for the list() function in validate-options.js from the svelte codebase.

Entity Profile

Dependency Diagram

graph TD
  04fae831_cbec_8ad5_e8d1_b283d27f3502["list()"]
  1c00ccb7_a603_4a1b_e865_0343036fc5ca["validate-options.js"]
  04fae831_cbec_8ad5_e8d1_b283d27f3502 -->|defined in| 1c00ccb7_a603_4a1b_e865_0343036fc5ca
  68d669a3_acf0_faef_1444_faa0cc8be7d0["validator()"]
  04fae831_cbec_8ad5_e8d1_b283d27f3502 -->|calls| 68d669a3_acf0_faef_1444_faa0cc8be7d0
  be8408ea_8ac5_f7b5_43ee_0abbed48e9bf["throw_error()"]
  04fae831_cbec_8ad5_e8d1_b283d27f3502 -->|calls| be8408ea_8ac5_f7b5_43ee_0abbed48e9bf
  style 04fae831_cbec_8ad5_e8d1_b283d27f3502 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/svelte/src/compiler/validate-options.js lines 294–306

function list(options, fallback = options[0]) {
	return validator(fallback, (input, keypath) => {
		if (!options.includes(input)) {
			// prettier-ignore
			const msg = options.length > 2
				? `${keypath} should be one of ${options.slice(0, -1).map(input => `"${input}"`).join(', ')} or "${options[options.length - 1]}"`
				: `${keypath} should be either "${options[0]}" or "${options[1]}"`;

			throw_error(msg);
		}
		return input;
	});
}

Domain

Subdomains

Frequently Asked Questions

What does list() do?
list() is a function in the svelte codebase, defined in packages/svelte/src/compiler/validate-options.js.
Where is list() defined?
list() is defined in packages/svelte/src/compiler/validate-options.js at line 294.
What does list() call?
list() calls 2 function(s): throw_error, validator.

Analyze Your Own Codebase

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

Try Supermodel Free