View Source DenoRider (DenoRider v0.2.0)
Summary
Functions
Returns a specification to start this module under a supervisor.
Same as eval/2
, but it assumes that there is a process with the name
DenoRider
(the default if you don't provide a name to start_link/1
).
Run the given JavaScript code and return the result. If a promise is returned, it will be awaited.
Same as eval/1
, but raises if the result isn't successful.
Same as eval/2
, but raises if the result isn't successful.
Start a DenoRider process without any main module.
Start a DenoRider process.
Start a DenoRider process linked to the current process.
Same as stop/1
, but it assumes that there is a process with the name
DenoRider
(the default if you don't provide a name to start_link/1
).
Stop a DenoRider process.
Functions
Returns a specification to start this module under a supervisor.
See Supervisor
.
@spec eval(binary()) :: {:ok, term()} | {:error, DenoRider.Error.t()}
Same as eval/2
, but it assumes that there is a process with the name
DenoRider
(the default if you don't provide a name to start_link/1
).
Examples
iex> DenoRider.eval("1 + 2")
{:ok, 3}
@spec eval(binary(), Keyword.t()) :: {:ok, term()} | {:error, DenoRider.Error.t()}
Run the given JavaScript code and return the result. If a promise is returned, it will be awaited.
Options
:blocking
- Indicates whether the NIF call should block until the JavaScript execution finishes or not. Blocking is more performant, but it can also cause problems if the call takes too long. The NIF documentation suggests that a NIF call shouldn't take more than 1 millisecond. Only set this totrue
if you need the performance boost and the execution stays below 1 millisecond or so. The default isfalse
.:name
- The name of the DenoRider process. The default isDenoRider
. Can't be provided if:pid
is provided.:pid
- The pid of the DenoRider process. Can't be provided if:name
is provided.
Examples
iex> DenoRider.eval("1 + 2")
{:ok, 3}
iex> DenoRider.eval("1 + 2", blocking: true)
{:ok, 3}
iex> DenoRider.start_link(name: :foo)
iex> DenoRider.eval("1 + 2", name: :foo)
{:ok, 3}
iex> {:ok, pid} = DenoRider.start()
iex> DenoRider.eval("1 + 2", pid: pid)
{:ok, 3}
Same as eval/1
, but raises if the result isn't successful.
Same as eval/2
, but raises if the result isn't successful.
@spec start() :: GenServer.on_start()
@spec start() :: GenServer.on_start()
Start a DenoRider process without any main module.
See start/1
for more information.
Examples
iex> {:ok, pid} = DenoRider.start()
iex> DenoRider.eval("1 + 2", pid: pid)
{:ok, 3}
Start a DenoRider process.
Options
:main_module_path
- Path to the main JavaScript module. The default is to start the runtime without a main module.
Examples
iex> DenoRider.start(main_module_path: "path/to/main.js")
@spec start_link(Keyword.t()) :: GenServer.on_start()
Start a DenoRider process linked to the current process.
Options
:name
- The name of the process. The default isDenoRider
.
See start/1
for more options.
Examples
iex> DenoRider.start_link(name: MyApp.DenoRider)
iex> DenoRider.eval("1 + 2", name: MyApp.DenoRider)
{:ok, 3}
@spec stop() :: :ok
Same as stop/1
, but it assumes that there is a process with the name
DenoRider
(the default if you don't provide a name to start_link/1
).
@spec stop(Keyword.t()) :: :ok
Stop a DenoRider process.
Options
:name
- The name of the DenoRider process. The default isDenoRider
. Can't be provided if:pid
is provided.:pid
- The pid of the DenoRider process. Can't be provided if:name
is provided.:reason
- SeeGenServer.stop/3
.:timeout
- SeeGenServer.stop/3
.
Examples
iex> {:ok, pid} = DenoRider.start()
iex> DenoRider.stop(pid: pid)
:ok