Create a JavaScript bundle of an odin model

odin_js_bundle(code, include = NULL, include_dopri = TRUE)

Arguments

code

An expression, string or path to a file containing odin code (as for odin_parse_

include

Optional vector of paths of filenames to include into the javascript bundle

include_dopri

Logical, indicating if the dopri solver should be included as well.

Warning

The interface and generated code here are subject to change.

Examples

js <- odin::odin_js_bundle(quote({
  deriv(x) <- 1
  initial(x) <- 1
}), include_dopri = FALSE)
head(js)
#> [1] "// V8 does not support Array.fill from the look of it"
#> [2] "function zeros(n) {"                                  
#> [3] "    var ret = new Array(n);"                          
#> [4] "    for (var i = 0; i < n; ++i) {"                    
#> [5] "        ret[i] = 0;"                                  
#> [6] "    }"