View Source IgniterJs.Parsers.Javascript.Parser (igniter_js v0.2.0)
Codemods for JavaScript files.
Summary
Functions
Check if a LiveSocket var exists in the given file or content and returns tuple.
Check if a LiveSocket var exists in the given file or content and returns boolean.
Extend the hook object in the given file or content. It accepts a single object or a list of objects. It returns a tuple.
Insert imports to the given file or content and returns tuple.
Check if a module is imported in the given file or content or contents and return tuple.
Check if a module is imported in the given file or content or content and returns boolean.
Remove imports from the given file or content. it accepts a single module or a list of modules. It returns a tuple.
Remove objects from the hooks in the given file or content. It accepts a single o bject or a list of objects. It returns a tuple.
Retrieve statistical information about the JavaScript source code, such as the number of functions, classes, debugger statements, imports, try-catch blocks, and throw statements.
Functions
Check if a LiveSocket var exists in the given file or content and returns tuple.
alias IgniterJs.Parsers.Javascript.Parser
Parser.exist_live_socket(js_content)
Parser.exist_live_socket(js_content, :content)
Parser.exist_live_socket("/path/to/file.js", :path)
Check if a LiveSocket var exists in the given file or content and returns boolean.
alias IgniterJs.Parsers.Javascript.Parser
Parser.exist_live_socket?(js_content)
Parser.exist_live_socket?(js_content, :content)
Parser.exist_live_socket?("/path/to/file.js", :path)
Extend the hook object in the given file or content. It accepts a single object or a list of objects. It returns a tuple.
alias IgniterJs.Parsers.Javascript.Parser
Parser.extend_hook_object(js_content, "SomeObject")
Parser.extend_hook_object(js_content, ["SomeObject", "AnotherObject"], :content)
Parser.extend_hook_object("/path/to/file.js", "SomeObject", :path)
Insert imports to the given file or content and returns tuple.
alias IgniterJs.Parsers.Javascript.Parser
Parser.insert_imports(js_content, imports_lines)
Parser.insert_imports(js_content, imports_lines, :content)
Parser.insert_imports("/path/to/file.js", imports_lines, :path)
Check if a module is imported in the given file or content or contents and return tuple.
alias IgniterJs.Parsers.Javascript.Parser
Parser.module_imported(js_content, "module")
Parser.module_imported(js_content, "module", :content)
Parser.module_imported("/path/to/file.js", "module", :path)
Check if a module is imported in the given file or content or content and returns boolean.
alias IgniterJs.Parsers.Javascript.Parser
Parser.module_imported?(js_content, "module")
Parser.module_imported?(js_content, "module", :content)
Parser.module_imported?("/path/to/file.js", "module", :path)
Remove imports from the given file or content. it accepts a single module or a list of modules. It returns a tuple.
alias IgniterJs.Parsers.Javascript.Parser
Parser.remove_imports(js_content, "SomeModule")
Parser.remove_imports(js_content, ["SomeModule", "AnotherModule"], :content)
Parser.remove_imports("/path/to/file.js", "SomeModule", :path)
Remove objects from the hooks in the given file or content. It accepts a single o bject or a list of objects. It returns a tuple.
alias IgniterJs.Parsers.Javascript.Parser
Parser.remove_objects_from_hooks(js_content, "SomeObject")
Parser.remove_objects_from_hooks(js_content, ["SomeObject", "AnotherObject"], :content)
Parser.remove_objects_from_hooks("/path/to/file.js", "SomeObject", :path)
Retrieve statistical information about the JavaScript source code, such as the number of functions, classes, debugger statements, imports, try-catch blocks, and throw statements.
This function accepts either the content of the JavaScript file or the path to the file, and returns a tuple with the status, function atom, and the extracted data as a map.
Examples
alias IgniterJs.Parsers.Javascript.Parser
# Analyze a JavaScript source file by providing its content
Parser.statistics(js_content)
# Analyze a JavaScript source file by providing its file path
Parser.statistics("/path/to/file.js", :path)