MCPcopy Create free account
hub / github.com/SchemaStore/schemastore / groupByDomain

Function groupByDomain

scripts/build-xregistry.js:100–112  ·  view source on GitHub ↗

* Groups schemas by their domain. * @param {Array<{ url: string }>} schemas - The schemas to group. * @returns {Record >} - The grouped schemas.

(schemas)

Source from the content-addressed store, hash-verified

98 * @returns {Record<string, Array<{ url: string }>>} - The grouped schemas.
99 */
100function groupByDomain(schemas) {
101 const grouped = /** @type {Record<string, Array<{ url: string }>>} */ ({})
102
103 for (const schema of schemas) {
104 const domain = extractDomain(schema.url)
105 if (!grouped[domain]) {
106 grouped[domain] = []
107 }
108 grouped[domain].push(schema)
109 }
110
111 return grouped
112}
113
114/**
115 * Parses a $schema URI into a format string.

Callers

nothing calls this directly

Calls 1

extractDomainFunction · 0.85

Tested by

no test coverage detected