MCPcopy Index your code
hub / github.com/JavaScriptRegenerated/yieldparser / lookup

Function lookup

src/modules.test.ts:343–364  ·  view source on GitHub ↗
(identifier: string)

Source from the content-addressed store, hash-verified

341
342 describe('lookup', () => {
343 function lookup(identifier: string) {
344 const result = parse(code, ESModuleParser());
345 if (!result.success) {
346 return;
347 }
348
349 for (const item of result.result as any[]) {
350 if (item.type === 'const') {
351 if (item.name === identifier) {
352 return item;
353 }
354 } else if (item.type === 'function') {
355 if (item.name === identifier) {
356 return item;
357 }
358 } else if (item.type === 'export') {
359 if (item.exported.name === identifier) {
360 return item.exported;
361 }
362 }
363 }
364 }
365
366 it('can lookup const', () => {
367 expect(lookup('a')).toEqual({

Callers 1

modules.test.tsFile · 0.85

Calls 2

parseFunction · 0.90
ESModuleParserFunction · 0.85

Tested by

no test coverage detected