MCPcopy
hub / github.com/jquery/esprima / tokenize

Function tokenize

src/esprima.ts:94–120  ·  view source on GitHub ↗
(code: string, options, delegate)

Source from the content-addressed store, hash-verified

92}
93
94export function tokenize(code: string, options, delegate) {
95 const tokenizer = new Tokenizer(code, options);
96
97 let tokens;
98 tokens = [];
99
100 try {
101 while (true) {
102 let token = tokenizer.getNextToken();
103 if (!token) {
104 break;
105 }
106 if (delegate) {
107 token = delegate(token);
108 }
109 tokens.push(token);
110 }
111 } catch (e) {
112 tokenizer.errorHandler.tolerate(e);
113 }
114
115 if (tokenizer.errorHandler.tolerant) {
116 tokens.errors = tokenizer.errors();
117 }
118
119 return tokens;
120}
121
122export { Syntax } from './syntax';
123

Callers

nothing calls this directly

Calls 4

getNextTokenMethod · 0.95
errorsMethod · 0.95
pushMethod · 0.80
tolerateMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…