NodeSession: NodeJS Session

Description Public fields Methods Examples

Description

Launch a NodeJS Session

Public fields

bin

Path to NodeJs bin directory.

handle

A handle as returned by spawn_process.

Methods

Public methods


Method new()

Usage
NodeSession$new(bin = NULL, params = "-i")
Arguments
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.

Details

Initialise a NodeJs session

Examples
\dontrun{
n <- NodeSession$new()
n$eval("17 + 29")
}

Method finalize()

Usage
NodeSession$finalize()
Details

Terminate a NodeJs session


Method eval()

Usage
NodeSession$eval(code, wait = TRUE, print = TRUE)
Arguments
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.

Details

Evaluate NodeJs code

Examples
\dontrun{
n <- NodeSession$new()
n$eval("17 + 29")
}

Method assign()

Usage
NodeSession$assign(name, value, type = c("var", "const"))
Arguments
name

Name of variable to create.post

value

Value to assign to variable.

type

Type of variable to define.

Details

Create NodeJs objects

Examples
\dontrun{
n <- NodeSession$new()
n$assign(carz, cars)
n$get(carz)
}

Method get()

Usage
NodeSession$get(var)
Arguments
var

Bare name of object to retrieve.

Details

Retrieve NodeJs objects

Examples
\dontrun{
n <- NodeSession$new()
n$eval("var x = 12")
n$get(x)
}

Method state()

Usage
NodeSession$state()
Details

Retrieve NodeJs state

Examples
\dontrun{
n <- NodeSession$new()
n$state()
n$kill()
n$state()
}

Method kill()

Usage
NodeSession$kill()
Details

Kill NodeJs

Examples
\dontrun{
n <- NodeSession$new()
n$kill()
n$state()
}

Method terminate()

Usage
NodeSession$terminate()
Details

Terminate NodeJs

Examples
\dontrun{
n <- NodeSession$new()
n$terminate()
n$state()
}

Method clone()

The objects of this class are cloneable with this method.

Usage
NodeSession$clone(deep = FALSE)
Arguments
deep

Whether to make a deep clone.

Examples

 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)

ColinFay/bubble documentation built on May 15, 2020, 1:47 p.m.