MCPcopy Create free account
hub / github.com/Effect-TS/effect / tokenize

Function tokenize

packages/effect/src/internal/schema/codeTokens.ts:20–39  ·  view source on GitHub ↗
(source: string)

Source from the content-addressed store, hash-verified

18)
19
20export function tokenize(source: string): Array<Token> {
21 const tokens: Array<Token> = []
22 for (const match of source.matchAll(pattern)) {
23 if (match[1] === undefined) {
24 tokens.push({
25 text: match[0],
26 start: match.index,
27 end: match.index + match[0].length,
28 kind: match[2] !== undefined
29 ? "identifier"
30 : match[3] !== undefined
31 ? "string"
32 : match[4] !== undefined
33 ? "number"
34 : "punctuation"
35 })
36 }
37 }
38 return tokens
39}

Callers 2

parseFunction · 0.90
parseFunction · 0.90

Calls 1

pushMethod · 0.65

Tested by

no test coverage detected