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

Function parseWord

src/pseudo_json.mjs:86–102  ·  view source on GitHub ↗
(stream, prop)

Source from the content-addressed store, hash-verified

84}
85
86function parseWord(stream, prop) {
87 let start = stream.pos
88 for (;;) {
89 let next = stream.next
90 if ((next >= 97 && next <= 122) || (next >= 65 && next <= 90) || next == 95 || (next >= 48 && next <= 57)) stream.pos++
91 else break
92 }
93 let word = stream.str.slice(start, stream.pos)
94 if (!word) stream.err("Expected word")
95 stream.space()
96 if (/^(?:0x[\da-f]+|\d*(?:\.\d*)?(?:[eE][+\-]?\d+)?)$/i.test(word)) return JSON.parse(word)
97 if (!prop) {
98 if (word == "true") return true
99 if (word == "false") return false
100 }
101 return word
102}

Callers 2

parseValueFunction · 0.85
parseObjFunction · 0.85

Calls 4

errMethod · 0.80
spaceMethod · 0.80
sliceMethod · 0.45
parseMethod · 0.45

Tested by

no test coverage detected