Description Public fields Methods Examples
Launch a NodeJS Session
bin
Path to NodeJs bin directory.
handle
A handle as returned by spawn_process.
new()
NodeSession$new(bin = NULL, params = "-i")
bin
Path to NodeJs bin directory, if NULL
then bubble
attemtpts to find the directory with find_node
.
params
Additional parameters to pass to the initialisation.
Initialise a NodeJs session
\dontrun{ n <- NodeSession$new() n$eval("17 + 29") }
finalize()
NodeSession$finalize()
Terminate a NodeJs session
eval()
NodeSession$eval(code, wait = TRUE, print = TRUE)
code
The code to evaluate.
wait
Whether to re-attempt to evaluate if it first fails.
print
Whether to print the result to the R console.
Evaluate NodeJs code
\dontrun{ n <- NodeSession$new() n$eval("17 + 29") }
assign()
NodeSession$assign(name, value, type = c("var", "const"))
name
Name of variable to create.post
value
Value to assign to variable.
type
Type of variable to define.
Create NodeJs objects
\dontrun{ n <- NodeSession$new() n$assign(carz, cars) n$get(carz) }
get()
NodeSession$get(var)
var
Bare name of object to retrieve.
Retrieve NodeJs objects
\dontrun{ n <- NodeSession$new() n$eval("var x = 12") n$get(x) }
state()
NodeSession$state()
Retrieve NodeJs state
\dontrun{ n <- NodeSession$new() n$state() n$kill() n$state() }
kill()
NodeSession$kill()
Kill NodeJs
\dontrun{ n <- NodeSession$new() n$kill() n$state() }
terminate()
NodeSession$terminate()
Terminate NodeJs
\dontrun{ n <- NodeSession$new() n$terminate() n$state() }
clone()
The objects of this class are cloneable with this method.
NodeSession$clone(deep = FALSE)
deep
Whether to make a deep clone.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 | ## ------------------------------------------------
## Method `NodeSession$new`
## ------------------------------------------------
## Not run:
n <- NodeSession$new()
n$eval("17 + 29")
## End(Not run)
## ------------------------------------------------
## Method `NodeSession$eval`
## ------------------------------------------------
## Not run:
n <- NodeSession$new()
n$eval("17 + 29")
## End(Not run)
## ------------------------------------------------
## Method `NodeSession$assign`
## ------------------------------------------------
## Not run:
n <- NodeSession$new()
n$assign(carz, cars)
n$get(carz)
## End(Not run)
## ------------------------------------------------
## Method `NodeSession$get`
## ------------------------------------------------
## Not run:
n <- NodeSession$new()
n$eval("var x = 12")
n$get(x)
## End(Not run)
## ------------------------------------------------
## Method `NodeSession$state`
## ------------------------------------------------
## Not run:
n <- NodeSession$new()
n$state()
n$kill()
n$state()
## End(Not run)
## ------------------------------------------------
## Method `NodeSession$kill`
## ------------------------------------------------
## Not run:
n <- NodeSession$new()
n$kill()
n$state()
## End(Not run)
## ------------------------------------------------
## Method `NodeSession$terminate`
## ------------------------------------------------
## Not run:
n <- NodeSession$new()
n$terminate()
n$state()
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.