IgniterJs.Parsers.Javascript.Formatter (igniter_js v0.4.6)

View Source

This module provides functions to check if a JavaScript file is formatted and to format JavaScript files. It interacts with the Native NIF (Native Implemented Functions) for performing the actual formatting and checking.

Summary

Functions

Checks if the provided JavaScript content or file is formatted.

Checks if the provided JavaScript content or file is formatted.

Functions

format(file_path_or_content, type \\ :content)

is_formatted(file_path_or_content, type \\ :content)

Checks if the provided JavaScript content or file is formatted.

This function returns the status of the formatting check.

Parameters

  • file_path_or_content: The JavaScript file path or content to check.
  • type: The type of the input, either :content or :path.

Examples

iex> IgniterJs.Parsers.Javascript.Formatter.is_formatted("path/to/file.js")
{:ok, :is_formatted, true}

is_formatted?(file_path_or_content, type \\ :content)

Checks if the provided JavaScript content or file is formatted.

This function returns true if the content is formatted, and false otherwise. The type can either be :content (default) or :path.

Parameters

  • file_path_or_content: The JavaScript file path or content to check.
  • type: The type of the input, either :content or :path.

Examples

iex> IgniterJs.Parsers.Javascript.Formatter.is_formatted?("path/to/file.js")
true