Home / Function/ object() — svelte Function Reference

object() — svelte Function Reference

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

Entity Profile

Dependency Diagram

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

Relationship Graph

Source Code

packages/svelte/src/compiler/validate-options.js lines 219–245

function object(children, allow_unknown = false) {
	return (input, keypath) => {
		/** @type {Record<string, any>} */
		const output = {};

		if ((input && typeof input !== 'object') || Array.isArray(input)) {
			throw_error(`${keypath} should be an object`);
		}

		for (const key in input) {
			if (!(key in children)) {
				if (allow_unknown) {
					output[key] = input[key];
				} else {
					e.options_unrecognised(null, `${keypath ? `${keypath}.${key}` : key}`);
				}
			}
		}

		for (const key in children) {
			const validator = children[key];
			output[key] = validator(input && input[key], keypath ? `${keypath}.${key}` : key);
		}

		return output;
	};
}

Domain

Subdomains

Frequently Asked Questions

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

Analyze Your Own Codebase

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

Try Supermodel Free