View Source DenoEx.Pipe (DenoEx v0.3.0)
The DenoEx pipe.
This module defines a struct and the main functions for working with deno pipes and their responses.
Link to this section Summary
Functions
returns if the pipe is finished running or not
Initializes a deno pipe with everything needed to run a deno script.
get the buffer from the desired datastream
Executes the deno pipe in another process and sets up to monitor the results.
Sends data to a running process
returns the exit code of a finished pipe
Waits for a pipe to finish and collects the results.
Link to this section Types
@type options() :: keyword( {:deno_location, binary()} | {:allow_env, boolean() | [binary()]} | {:allow_sys, boolean() | [binary()]} | {:allow_net, boolean() | [binary()]} | {:allow_hrtime, boolean()} | {:allow_ffi, boolean() | [binary()]} | {:allow_run, boolean() | [binary()]} | {:allow_write, boolean() | [binary()]} | {:allow_read, boolean() | [binary()]} | {:allow_all, boolean()} )
arguments for deno
@type status() :: :initialized | :running | {:exited, :normal | pos_integer()} | :timeout
status of the pipe
@opaque t()
Elixir.DenoEx.Pipe
@opaque t(status)
Link to this section Functions
returns if the pipe is finished running or not
@spec new(DenoEx.script(), DenoEx.script_arguments(), options()) :: t(:initialized) | {:error, String.t()}
Initializes a deno pipe with everything needed to run a deno script.
## Options
:deno_location
(String.t/0
) - Sets the path where the deno executable is located.
Note: It does not include the deno executable. If the executable is located at
/usr/bin/deno
then the deno_location
should be /usr/bin
.
:allow_env
- Allows read and write access to environment variables.true
: allows full access to the environment variables[String.t()]
: allows access to only the subset of variables in the list.:allow_sys
- Allows access to APIs that provide system information. i.e. hostname, memory usagetrue
: allows full access[String.t()]
: allows access to only the subset calls. hostname, osRelease, osUptime, loadavg, networkInterfaces, systemMemoryInfo, uid, and gid:allow_net
- Allows network access.true
: allows full access to the network[String.t()]
: allows access to only the network connections specified ie. 127.0.0.1:4000, 127.0.0.1, :4001:allow_hrtime
(boolean/0
) - Allows high-resolution time measurement. High-resolution time can be used in timing attacks and fingerprinting.:allow_ffi
- Allow loading of dynamic libraries.warning
WARNING:Be aware that dynamic libraries are not run in a sandbox and therefore do not have the same security restrictions as the Deno process. Therefore, use it with caution.
true
: allows all dlls to be accessed[Path.t()]
: A list of paths to dlls that will be accessible:allow_run
- Allow running subprocesses.warning-1
WARNINGBe aware that subprocesses are not run in a sandbox and therefore do not have the same security restrictions as the Deno process. Therefore, use it with caution.
true
: allows all subprocesses to be run[Path.t()]
: A list of subprocesses to run:allow_write
- Allow the ability to write files.true
: allows all files to be written[Path.t()]
: A list of files that can be written:allow_read
- Allow the ability to read files.true
: allows all files to be read[Path.t()]
: A list of files that can be read:allow_all
(boolean/0
) - Turns on all options and bypasses all security measuresPlease refer to Deno Permissions for more details.
examples
Examples
iex> DenoEx.Pipe.new({:file, Path.join(~w[test support hello.ts])})
#DenoEx.Pipe<status: :initialized, ...>
iex> DenoEx.Pipe.new({:file, Path.join(~w[test support args_echo.ts])}, ~w[foo bar])
#DenoEx.Pipe<status: :initialized, ...>
get the buffer from the desired datastream
Executes the deno pipe in another process and sets up to monitor the results.
While running a Deno.Pipe
sends messages back to the calling process.
examples
Examples
iex> DenoEx.Pipe.new({:file, Path.join(~w[test support hello.ts])}) |> DenoEx.Pipe.run()
#DenoEx.Pipe<status: :running, ...>
Sends data to a running process
returns the exit code of a finished pipe
@spec yield(t(:running), timeout()) :: {:ok, t({:exit, :normal})} | {:error, t({:exit, pos_integer()})} | {:timeout, t(:timeout)}
Waits for a pipe to finish and collects the results.
examples
Examples
iex> {:ok, pipe} = DenoEx.Pipe.new({:file, Path.join(~w[test support hello.ts])}) |> DenoEx.Pipe.run() |> DenoEx.Pipe.yield()
iex> pipe
#DenoEx.Pipe<status: {:exit, :normal}, ...>
iex> {:timeout, pipe} = DenoEx.Pipe.new({:file, Path.join(~w[test support hello.ts])}) |> DenoEx.Pipe.run() |> DenoEx.Pipe.yield(1)
iex> pipe
#DenoEx.Pipe<status: :timeout, ...>