MCPcopy Create free account
hub / github.com/breck7/scroll / resolveMode

Function resolveMode

external/.scrollLibs.js:2197–2217  ·  view source on GitHub ↗
(spec)

Source from the content-addressed store, hash-verified

2195 // Given a MIME type, a {name, ...options} config object, or a name
2196 // string, return a mode config object.
2197 function resolveMode(spec) {
2198 if (typeof spec == "string" && mimeModes.hasOwnProperty(spec)) {
2199 spec = mimeModes[spec]
2200 } else if (spec && typeof spec.name == "string" && mimeModes.hasOwnProperty(spec.name)) {
2201 var found = mimeModes[spec.name]
2202 if (typeof found == "string") {
2203 found = { name: found }
2204 }
2205 spec = createObj(found, spec)
2206 spec.name = found.name
2207 } else if (typeof spec == "string" && /^[\w\-]+\/[\w\-]+\+xml$/.test(spec)) {
2208 return resolveMode("application/xml")
2209 } else if (typeof spec == "string" && /^[\w\-]+\/[\w\-]+\+json$/.test(spec)) {
2210 return resolveMode("application/json")
2211 }
2212 if (typeof spec == "string") {
2213 return { name: spec }
2214 } else {
2215 return spec || { name: "null" }
2216 }
2217 }
2218
2219 // Given a mode spec (anything that resolveMode accepts), find and
2220 // initialize an actual mode object.

Callers 1

getModeFunction · 0.85

Calls 1

createObjFunction · 0.85

Tested by

no test coverage detected