diff --git a/DESCRIPTION b/DESCRIPTION index c53f834..4f9e471 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: QuickJSR Title: Interface for the 'QuickJS' Lightweight 'JavaScript' Engine -Version: 1.2.0.9000 +Version: 1.2.2 Authors@R: c( person(c("Andrew", "R."), "Johnson", , "andrew.johnson@arjohnsonau.com", role = c("aut", "cre"), comment = c(ORCID = "0000-0001-7000-8065")), diff --git a/NEWS.md b/NEWS.md index d97d739..8b65e33 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,7 @@ -# QuickJSR 1.2.0 +# QuickJSR 1.2.2 + - Fix non-canonical CRAN URL in READMEE + +# QuickJSR 1.2.1 - Fix installation under C++11 - Fix installation for FreeBSD - Fix detection of atomics support under Windows and ARM64 diff --git a/README.Rmd b/README.Rmd index 2546300..a7f2582 100644 --- a/README.Rmd +++ b/README.Rmd @@ -18,7 +18,7 @@ knitr::opts_chunk$set( [![R-CMD-check](https://github.com/andrjohns/QuickJSR/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/andrjohns/QuickJSR/actions/workflows/R-CMD-check.yaml) [![CRAN status](https://www.r-pkg.org/badges/version/QuickJSR)](https://CRAN.R-project.org/package=QuickJSR) -[![Downloads](https://cranlogs.r-pkg.org/badges/QuickJSR?color=blue)](https://cran.rstudio.com/package=QuickJSR) +[![Downloads](https://cranlogs.r-pkg.org/badges/QuickJSR?color=blue)](https://CRAN.R-project.org/package=QuickJSR) [![QuickJSR status badge](https://andrjohns.r-universe.dev/badges/QuickJSR)](https://andrjohns.r-universe.dev/QuickJSR) @@ -66,8 +66,9 @@ Use the `$source()` method to load JavaScript code into the context: ctx$source(code = "function add(a, b) { return a + b; }") # Or read from a file -writeLines("function subtract(a, b) { return a - b; }", "subtract.js") -ctx$source(file = "subtract.js") +subtract_js <- tempfile(fileext = ".js") +writeLines("function subtract(a, b) { return a - b; }", subtract_js) +ctx$source(file = subtract_js) ``` Then use the `$call()` method to call a specified function with arguments: @@ -108,6 +109,5 @@ env$z QuickJSR also provides a global `R` object, which you can use to access objects and functions from various R packages: ```{r} -ctx$source(code = 'function callRFunctionFromPackage() { return R.package("base")["Sys.Date"](); }') -ctx$call("callRFunctionFromPackage") +qjs_eval('R.package("base")["Sys.Date"]()') ``` diff --git a/README.md b/README.md index fb0340e..59a926c 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ [![R-CMD-check](https://github.com/andrjohns/QuickJSR/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/andrjohns/QuickJSR/actions/workflows/R-CMD-check.yaml) [![CRAN status](https://www.r-pkg.org/badges/version/QuickJSR)](https://CRAN.R-project.org/package=QuickJSR) -[![Downloads](https://cranlogs.r-pkg.org/badges/QuickJSR?color=blue)](https://cran.rstudio.com/package=QuickJSR) +[![Downloads](https://cranlogs.r-pkg.org/badges/QuickJSR?color=blue)](https://CRAN.R-project.org/package=QuickJSR) [![QuickJSR status badge](https://andrjohns.r-universe.dev/badges/QuickJSR)](https://andrjohns.r-universe.dev/QuickJSR) @@ -52,7 +52,7 @@ qjs_eval("1 + 1") ``` r qjs_eval("Math.random()") -#> [1] 0.7978077 +#> [1] 0.5193045 ``` For more complex interactions, you can create a QuickJS context and @@ -69,8 +69,9 @@ Use the `$source()` method to load JavaScript code into the context: ctx$source(code = "function add(a, b) { return a + b; }") # Or read from a file -writeLines("function subtract(a, b) { return a - b; }", "subtract.js") -ctx$source(file = "subtract.js") +subtract_js <- tempfile(fileext = ".js") +writeLines("function subtract(a, b) { return a - b; }", subtract_js) +ctx$source(file = subtract_js) ``` Then use the `$call()` method to call a specified function with @@ -136,7 +137,6 @@ QuickJSR also provides a global `R` object, which you can use to access objects and functions from various R packages: ``` r -ctx$source(code = 'function callRFunctionFromPackage() { return R.package("base")["Sys.Date"](); }') -ctx$call("callRFunctionFromPackage") -#> [1] "2024-06-03 03:00:00 EEST" +qjs_eval('R.package("base")["Sys.Date"]()') +#> [1] "2024-06-07 03:00:00 EEST" ```