View Source NodeJS (NodeJS v3.2.0)

Summary

Functions

Calls a Node.js function. Returns {:ok, result} if the call is successful, or {:error, reason} if the call fails.

Calls a Node.js function. Returns the result if the call is successful, or raises NodeJS.Error.

Functions

Link to this function

call(module, args \\ [], opts \\ [])

View Source

Calls a Node.js function. Returns {:ok, result} if the call is successful, or {:error, reason} if the call fails.

Options

  • :timeout (optional): The timeout (in milliseconds) for the call. Defaults to 30 seconds.
  • :esm (optional): Whether to load the module as ESM. Defaults to true when the module filename ends in .mjs, otherwise false.
  • :binary (optional): Whether to return the response in binary form. Defaults to false.

Examples

> NodeJS.call({"markdown-renderer.js", :renderHTML}, [inputMarkdown], esm: true)
{:ok, "<html>...</html>"}
Link to this function

call!(module, args \\ [], opts \\ [])

View Source

Calls a Node.js function. Returns the result if the call is successful, or raises NodeJS.Error.

Options

See call/3 for options.

Example

> NodeJS.call!({"markdown-renderer.js", :renderHTML}, [inputMarkdown], esm: true)
"<html>...</html>"