MCPcopy Index your code
hub / github.com/braziljs/eloquente-javascript / guessType

Function guessType

src/client/code.mjs:9–20  ·  view source on GitHub ↗
(doc)

Source from the content-addressed store, hash-verified

7const contextFacet = Facet.define({combine: vs => vs[0]})
8
9function guessType(doc) {
10 let scan
11 if (typeof doc == "string") {
12 scan = doc
13 } else {
14 for (let i = 1; i <= doc.lines; i++) {
15 let line = doc.line(i).text
16 if (/\S/.test(line)) { scan = line; break }
17 }
18 }
19 return /^[\s\w]*</.test(scan) ? "html" : "javascript"
20}
21
22const modeGuesser = EditorState.transactionExtender.of(tr => {
23 let guessed

Callers 3

code.mjsFile · 0.70
setEditorStateMethod · 0.70
selectContextMethod · 0.70

Calls 1

lineMethod · 0.45

Tested by

no test coverage detected