MCPcopy
hub / github.com/esm-dev/esm.sh / Parse

Function Parse

internal/importmap/importmap.go:121–138  ·  view source on GitHub ↗

Parse parses an importmap from a JSON string.

(baseUrl *url.URL, data []byte)

Source from the content-addressed store, hash-verified

119
120// Parse parses an importmap from a JSON string.
121func Parse(baseUrl *url.URL, data []byte) (im *ImportMap, err error) {
122 var importMapRaw ImportMapJson
123 if err = json.Unmarshal(data, &importMapRaw); err != nil {
124 return
125 }
126 scopes := make(map[string]*Imports)
127 for scope, imports := range importMapRaw.Scopes {
128 scopes[scope] = newImports(imports)
129 }
130 im = &ImportMap{
131 baseUrl: baseUrl,
132 config: importMapRaw.Config,
133 Imports: newImports(importMapRaw.Imports),
134 scopes: scopes,
135 integrity: newImports(importMapRaw.Integrity),
136 }
137 return
138}
139
140// Config returns the config of the import map.
141func (im *ImportMap) Config() Config {

Callers 6

tidyFunction · 0.92
updateImportMapFunction · 0.92
esmRouterFunction · 0.92
ServeHtmlMethod · 0.92
ServeFrameworkCSSMethod · 0.92
getAppImportMapMethod · 0.92

Calls 1

newImportsFunction · 0.85

Tested by

no test coverage detected