castborg
SourceCode
Represents code <--> AST
Can be initialized with a code, an AST or a file path
// by codevar sourceCode = code: 'var obj = { a: 1, b: 2 };' ;// by ASTvar sourceCode = ast: some_ast_object ;// by filevar sourceCode = file: './some-file.js' ;
All source code
instances have ast
, code
and filename
properties
var ast = sourceCodeast;var code = sourceCodecode;var file_name = sourceCodefile;
AstSearcher
AstSearcher has only static method that parse an AST and return a path
AstModifier
AstModifier has only static method that can modify an AST It will then return a new copy of the existing code / AST / filepath.