View Source IgniterJs.Parsers.Javascript.Parser (igniter_js v0.1.1)

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.

Functions

exist_live_socket(file_path_or_content, type \\ :content)

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)

exist_live_socket?(file_path_or_content, type \\ :content)

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_hook_object(file_path_or_content, object_name, type \\ :content)

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(file_path_or_content, imports_lines, type \\ :content)

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)

module_imported(file_path_or_content, module, type \\ :content)

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)

module_imported?(file_path_or_content, module, type \\ :content)

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(file_path_or_content, module, type \\ :content)

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_hooks(file_path_or_content, object_name, type \\ :content)

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)