All files / kernel-agents-repl/src/strategies/repl/parse javascript.ts

100% Statements 4/4
100% Branches 0/0
100% Functions 1/1
100% Lines 3/3

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14      6x 6x               124x  
import Parser from 'tree-sitter';
import JavaScript from 'tree-sitter-javascript';
 
const parser = new Parser();
parser.setLanguage(JavaScript as Parser.Language);
 
/**
 * Parse a JavaScript statement into a tree-sitter abstract syntax tree.
 *
 * @param text - The text to parse.
 * @returns The parsed tree-sitter abstract syntax tree.
 */
export const parse = (text: string): Parser.Tree => parser.parse(text);