ts/search.json

2 lines
21 KiB
JSON
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

[{"path":"http://tomelliott.co.nz/ts/LICENSE.html","id":null,"dir":"","previous_headings":"","what":"MIT License","title":"MIT License","text":"Copyright (c) 2024 Tom Elliott Permission hereby granted, free charge, person obtaining copy software associated documentation files (“Software”), deal Software without restriction, including without limitation rights use, copy, modify, merge, publish, distribute, sublicense, /sell copies Software, permit persons Software furnished , subject following conditions: copyright notice permission notice shall included copies substantial portions Software. SOFTWARE PROVIDED “”, WITHOUT WARRANTY KIND, EXPRESS IMPLIED, INCLUDING LIMITED WARRANTIES MERCHANTABILITY, FITNESS PARTICULAR PURPOSE NONINFRINGEMENT. EVENT SHALL AUTHORS COPYRIGHT HOLDERS LIABLE CLAIM, DAMAGES LIABILITY, WHETHER ACTION CONTRACT, TORT OTHERWISE, ARISING , CONNECTION SOFTWARE USE DEALINGS SOFTWARE.","code":""},{"path":"http://tomelliott.co.nz/ts/articles/simple-react-app.html","id":"install-the-ts-package","dir":"Articles","previous_headings":"","what":"Install the ts package","title":"Build a simple ReactJS app","text":"","code":"devtools::install_github('tmelliott/ts')"},{"path":"http://tomelliott.co.nz/ts/articles/simple-react-app.html","id":"write-the-r-code","dir":"Articles","previous_headings":"","what":"Write the R code","title":"Build a simple ReactJS app","text":"code saved file called faithful-app.R, can preview results calling functions: s ! ll use ts_compile() later create server code Typescript schema app.","code":"cat(readLines('faithful-app.R'), sep = '\\n') #> library(ts) #> #> get_hist <- ts_function( #> function(bins = ts_integer(1)) { #> h <- hist(faithful$waiting, breaks = bins, plot = FALSE) #> data.frame(x = h$mids, y = h$density) #> }, #> result = ts_dataframe(x = ts_numeric(0), y = ts_numeric(0)) #> ) #> get_smoother <- ts_function( #> function(bandwidth = ts_numeric(1)) { #> d <- density(faithful$waiting, bw = bandwidth) #> data.frame(x = d$x, y = d$y) #> }, #> result = ts_dataframe(x = ts_numeric(0), y = ts_numeric(0)) #> ) source('faithful-app.R') get_hist$call(10) #> x y #> 1 42.5 0.0029411765 #> 2 47.5 0.0161764706 #> 3 52.5 0.0242647059 #> 4 57.5 0.0176470588 #> 5 62.5 0.0102941176 #> 6 67.5 0.0073529412 #> 7 72.5 0.0198529412 #> 8 77.5 0.0397058824 #> 9 82.5 0.0404411765 #> 10 87.5 0.0169117647 #> 11 92.5 0.0036764706 #> 12 97.5 0.0007352941"},{"path":"http://tomelliott.co.nz/ts/articles/simple-react-app.html","id":"create-the-react-app","dir":"Articles","previous_headings":"","what":"Create the React app","title":"Build a simple ReactJS app","text":"now able see default Vite app running http://localhost:5173 (similar, see console output). Now install rserve-ts zod packages:","code":"pnpm create vite faithful-demo --template vanilla-ts cd faithful-demo pnpm install pnpm run dev pnpm install rserve-ts zod"},{"path":"http://tomelliott.co.nz/ts/articles/simple-react-app.html","id":"create-the-server-code","dir":"Articles","previous_headings":"Create the React app","what":"Create the server code","title":"Build a simple ReactJS app","text":"now use ts_compile() function create two files: faithful-app.rserve.R file start Rserve instance apps functions available. faithful-app.rserve.ts contains TypeScript schema (using zod) let use R functions directly app like typescript function! ll send straight faithful-demo/src directory.","code":"ts_compile('faithful-app.R', filename = 'faithful-demo/src/faithful-app.rserve')"},{"path":"http://tomelliott.co.nz/ts/articles/simple-react-app.html","id":"write-the-app","dir":"Articles","previous_headings":"Create the React app","what":"Write the app","title":"Build a simple ReactJS app","text":"rest process simply requires writing TypeScript code. wont go detail since s focus vignette, can see code written basic comments. Copy paste get app running.","code":"// main.ts"},{"path":"http://tomelliott.co.nz/ts/authors.html","id":null,"dir":"","previous_headings":"","what":"Authors","title":"Authors and Citation","text":"Tom Elliott. Author, maintainer.","code":""},{"path":"http://tomelliott.co.nz/ts/authors.html","id":"citation","dir":"","previous_headings":"","what":"Citation","title":"Authors and Citation","text":"Elliott T (2025). ts: Helper functions writing type safe functions rserve-ts. R package version 0.0.0.9000, http://tomelliott.co.nz/ts/.","code":"@Manual{, title = {ts: Helper functions for writing type safe functions for rserve-ts}, author = {Tom Elliott}, year = {2025}, note = {R package version 0.0.0.9000}, url = {http://tomelliott.co.nz/ts/}, }"},{"path":"http://tomelliott.co.nz/ts/index.html","id":"ts-write-apps-with-r-rserve-and-typescript","dir":"","previous_headings":"","what":"Helper functions for writing type safe functions for rserve-ts","title":"Helper functions for writing type safe functions for rserve-ts","text":"ts package makes easy users write functions can used rserve-ts applications.","code":""},{"path":"http://tomelliott.co.nz/ts/index.html","id":"installation","dir":"","previous_headings":"","what":"Installation","title":"Helper functions for writing type safe functions for rserve-ts","text":"can install development version ts GitHub :","code":"# install.packages(\"devtools\") devtools::install_github(\"tmelliott/ts\")"},{"path":"http://tomelliott.co.nz/ts/index.html","id":"example","dir":"","previous_headings":"","what":"Example","title":"Helper functions for writing type safe functions for rserve-ts","text":"Writing functions easy, just use ts_*() functions define formals return types. use ts_compile() generate TypeScript schemas: can import rserve-ts application. See tests/testthat/sampler example. also possible generate sourceable file deploy Rserve instance app code using ts_deploy():","code":"# demo.R library(ts) addFn <- ts_function( function(a = ts_numeric(1), b = ts_numeric(1)) a + b, result = ts_numeric(1) ) sampleFn <- ts_function( function(x = ts_character(), n = ts_integer(1)) sample(x, n), result = ts_character() ) app <- ts_function( function() { list( add = addFn, sample = sampleFn ) }, result = ts_list( add = addFn, sample = sampleFn ) ) # TODO: specify exactly which functions to export in the entry point # ts_export(app) import { Robj } from 'rserve-ts'; import { z } from 'zod'; const addFn = Robj.ocap([z.number(), z.number()], Robj.numeric(1)); const app = Robj.ocap([], Robj.list({ add: Robj.ocap(), sample: Robj.ocap() }) ); const sampleFn = Robj.ocap( [z.union([z.string(), z.array(z.string())]), z.number()], Robj.character() ); export default { addFn, app, sampleFn }; ts_deploy(app) # run with: Rscript app.rserve.R"},{"path":"http://tomelliott.co.nz/ts/reference/ts_app.html","id":null,"dir":"Reference","previous_headings":"","what":"Generate an Rserve app from a ts function — ts_app","title":"Generate an Rserve app from a ts function — ts_app","text":"Anything function simply returns . However, functions wrapped Rserve::ocap(), result subsequently wrapped ts_app().","code":""},{"path":"http://tomelliott.co.nz/ts/reference/ts_app.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Generate an Rserve app from a ts function — ts_app","text":"","code":"ts_app(x)"},{"path":"http://tomelliott.co.nz/ts/reference/ts_app.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Generate an Rserve app from a ts function — ts_app","text":"x ts function object (ts_function())","code":""},{"path":"http://tomelliott.co.nz/ts/reference/ts_character.html","id":null,"dir":"Reference","previous_headings":"","what":"Character or string type — ts_character","title":"Character or string type — ts_character","text":"Strings represented Zod schema either string (z.string()), string array (z.array(z.string())).","code":""},{"path":"http://tomelliott.co.nz/ts/reference/ts_character.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Character or string type — ts_character","text":"","code":"ts_character(n = -1L)"},{"path":"http://tomelliott.co.nz/ts/reference/ts_character.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Character or string type — ts_character","text":"n length string vector. n = 1 single string expected. n = 0 length expected. n > 1 string vector length n expected.","code":""},{"path":"http://tomelliott.co.nz/ts/reference/ts_character.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Character or string type — ts_character","text":"ts object accepts strings string vectors length n.","code":""},{"path":"http://tomelliott.co.nz/ts/reference/ts_compile.html","id":null,"dir":"Reference","previous_headings":"","what":"Compile R functions — ts_compile","title":"Compile R functions — ts_compile","text":"Generates TypeScript schema given R function file path. path, R app also generated.","code":""},{"path":"http://tomelliott.co.nz/ts/reference/ts_compile.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Compile R functions — ts_compile","text":"","code":"ts_compile(f, ..., name, filename)"},{"path":"http://tomelliott.co.nz/ts/reference/ts_compile.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Compile R functions — ts_compile","text":"f function file path ... Additional arguments (passed ts_deploy) name name function filename base file path write TypeScript schema R app (optional, uses [path f].rserve default). .R .ts file extensions appended automatically. \"\", output printed standard output console (see cat).","code":""},{"path":"http://tomelliott.co.nz/ts/reference/ts_compile.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Compile R functions — ts_compile","text":"Character vector TypeScript schema, NULL writing file","code":""},{"path":"http://tomelliott.co.nz/ts/reference/ts_dataframe.html","id":null,"dir":"Reference","previous_headings":"","what":"Typed dataframe — ts_dataframe","title":"Typed dataframe — ts_dataframe","text":"essentially list, elements must names length.","code":""},{"path":"http://tomelliott.co.nz/ts/reference/ts_dataframe.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Typed dataframe — ts_dataframe","text":"","code":"ts_dataframe(...)"},{"path":"http://tomelliott.co.nz/ts/reference/ts_dataframe.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Typed dataframe — ts_dataframe","text":"... Named types.","code":""},{"path":"http://tomelliott.co.nz/ts/reference/ts_dataframe.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Typed dataframe — ts_dataframe","text":"ts object accepts data frames specified types.","code":""},{"path":"http://tomelliott.co.nz/ts/reference/ts_deploy.html","id":null,"dir":"Reference","previous_headings":"","what":"Deploy a ts Rserve app — ts_deploy","title":"Deploy a ts Rserve app — ts_deploy","text":"Deploy ts Rserve app","code":""},{"path":"http://tomelliott.co.nz/ts/reference/ts_deploy.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Deploy a ts Rserve app — ts_deploy","text":"","code":"ts_deploy( f, file = sprintf(\"%s.rserve.R\", tools::file_path_sans_ext(f)), init = NULL, port = 6311, run = c(\"no\", \"here\", \"background\"), silent = FALSE )"},{"path":"http://tomelliott.co.nz/ts/reference/ts_deploy.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Deploy a ts Rserve app — ts_deploy","text":"f path application files file file write deployment script init Names objects (ts_functions) make available initialisation function port port deploy app run Whether run deployment script, takes values \"\", \"\", \"background\" silent Whether print deployment script","code":""},{"path":"http://tomelliott.co.nz/ts/reference/ts_deploy.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Deploy a ts Rserve app — ts_deploy","text":"NULL, called open Rserve instance","code":""},{"path":"http://tomelliott.co.nz/ts/reference/ts_factor.html","id":null,"dir":"Reference","previous_headings":"","what":"Typed factor — ts_factor","title":"Typed factor — ts_factor","text":"Factors integers labels. JS side, always represented string array (even one value - yay!).","code":""},{"path":"http://tomelliott.co.nz/ts/reference/ts_factor.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Typed factor — ts_factor","text":"","code":"ts_factor(levels = NULL)"},{"path":"http://tomelliott.co.nz/ts/reference/ts_factor.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Typed factor — ts_factor","text":"levels character vector levels (optional).","code":""},{"path":"http://tomelliott.co.nz/ts/reference/ts_factor.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Typed factor — ts_factor","text":"ts object accepts factors specified levels.","code":""},{"path":"http://tomelliott.co.nz/ts/reference/ts_function.html","id":null,"dir":"Reference","previous_headings":"","what":"TS function definition — ts_function","title":"TS function definition — ts_function","text":"TS function definition","code":""},{"path":"http://tomelliott.co.nz/ts/reference/ts_function.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"TS function definition — ts_function","text":"","code":"ts_function(f, ..., result = ts_void())"},{"path":"http://tomelliott.co.nz/ts/reference/ts_function.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"TS function definition — ts_function","text":"f R function ... argument definitions (required f specify formals) result return type (ignored overloads provided)","code":""},{"path":"http://tomelliott.co.nz/ts/reference/ts_integer.html","id":null,"dir":"Reference","previous_headings":"","what":"Integer type — ts_integer","title":"Integer type — ts_integer","text":"Integers represented Zod schema either number (z.number()), Int32Array (z.instanceof(Int32Array)).","code":""},{"path":"http://tomelliott.co.nz/ts/reference/ts_integer.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Integer type — ts_integer","text":"","code":"ts_integer(n = -1L)"},{"path":"http://tomelliott.co.nz/ts/reference/ts_integer.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Integer type — ts_integer","text":"n length integer vector. n = 1 single integer expected. n = 0 length expected. n > 1 integer vector length n expected.","code":""},{"path":"http://tomelliott.co.nz/ts/reference/ts_integer.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Integer type — ts_integer","text":"ts object accepts integer scalars vectors length n.","code":""},{"path":"http://tomelliott.co.nz/ts/reference/ts_list.html","id":null,"dir":"Reference","previous_headings":"","what":"Typed list — ts_list","title":"Typed list — ts_list","text":"list vector robjects, may may named.","code":""},{"path":"http://tomelliott.co.nz/ts/reference/ts_list.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Typed list — ts_list","text":"","code":"ts_list(...)"},{"path":"http://tomelliott.co.nz/ts/reference/ts_list.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Typed list — ts_list","text":"... list types, named unnamed.","code":""},{"path":"http://tomelliott.co.nz/ts/reference/ts_list.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Typed list — ts_list","text":"ts object accepts lists specified types.","code":""},{"path":"http://tomelliott.co.nz/ts/reference/ts_logical.html","id":null,"dir":"Reference","previous_headings":"","what":"Logical or boolean type — ts_logical","title":"Logical or boolean type — ts_logical","text":"Booleans represented Zod schema either boolean (z.boolean()), typed Uint8Array (z.instanceof(Uint8Array)).","code":""},{"path":"http://tomelliott.co.nz/ts/reference/ts_logical.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Logical or boolean type — ts_logical","text":"","code":"ts_logical(n = -1L)"},{"path":"http://tomelliott.co.nz/ts/reference/ts_logical.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Logical or boolean type — ts_logical","text":"n length boolean vector. n = 1 single boolean expected. n = 0 length expected. n > 1 boolean vector length n expected.","code":""},{"path":"http://tomelliott.co.nz/ts/reference/ts_logical.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Logical or boolean type — ts_logical","text":"ts object accepts logical scalars vectors length n.","code":""},{"path":"http://tomelliott.co.nz/ts/reference/ts_null.html","id":null,"dir":"Reference","previous_headings":"","what":"Null type — ts_null","title":"Null type — ts_null","text":"type accepts NULL.","code":""},{"path":"http://tomelliott.co.nz/ts/reference/ts_null.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Null type — ts_null","text":"","code":"ts_null()"},{"path":"http://tomelliott.co.nz/ts/reference/ts_null.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Null type — ts_null","text":"ts object accepts NULL.","code":""},{"path":"http://tomelliott.co.nz/ts/reference/ts_numeric.html","id":null,"dir":"Reference","previous_headings":"","what":"Numeric type — ts_numeric","title":"Numeric type — ts_numeric","text":"Numbers represented Zod schema either number (z.number()), Float64Array (z.instanceof(Float64Array)).","code":""},{"path":"http://tomelliott.co.nz/ts/reference/ts_numeric.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Numeric type — ts_numeric","text":"","code":"ts_numeric(n = -1L)"},{"path":"http://tomelliott.co.nz/ts/reference/ts_numeric.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Numeric type — ts_numeric","text":"n length numeric vector. n = 1 single number expected. n = 0 length expected. n > 1 numeric vector length n expected.","code":""},{"path":"http://tomelliott.co.nz/ts/reference/ts_numeric.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Numeric type — ts_numeric","text":"ts object accepts numeric scalars vectors length n.","code":""},{"path":"http://tomelliott.co.nz/ts/reference/ts_object.html","id":null,"dir":"Reference","previous_headings":"","what":"Typed object — ts_object","title":"Typed object — ts_object","text":"base type typed objects. meant used directly.","code":""},{"path":"http://tomelliott.co.nz/ts/reference/ts_object.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Typed object — ts_object","text":"","code":"ts_object( input_type = \"any\", return_type = \"any\", default = NULL, check = function() stop(\"Not implemented\"), generic = FALSE ) is_ts_object(x) get_type(x, which = c(\"input\", \"return\")) check_type(type, x)"},{"path":"http://tomelliott.co.nz/ts/reference/ts_object.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Typed object — ts_object","text":"input_type type object Typescript expect send R. return_type type object Typescript expects recieve R. default default value object. check function checks object returns valid. operates R side mostly development debugging purposes. developer ensure functions return correct type object always. generic logical, TRUE object generic type. x object type get, either \"input\" \"return\" type ts object","code":""},{"path":"http://tomelliott.co.nz/ts/reference/ts_object.html","id":"functions","dir":"Reference","previous_headings":"","what":"Functions","title":"Typed object — ts_object","text":"is_ts_object(): Check object ts object get_type(): Get input type ts object check_type(): Check object correct type","code":""},{"path":"http://tomelliott.co.nz/ts/reference/ts_void.html","id":null,"dir":"Reference","previous_headings":"","what":"Void type — ts_void","title":"Void type — ts_void","text":"type accepts null values (typically used functions return nothing).","code":""},{"path":"http://tomelliott.co.nz/ts/reference/ts_void.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Void type — ts_void","text":"","code":"ts_void()"},{"path":"http://tomelliott.co.nz/ts/reference/ts_void.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Void type — ts_void","text":"ts object accepts NULL.","code":""}]