diff --git a/src/webR/webr-main.ts b/src/webR/webr-main.ts index 4cc8c31c..7dc09105 100644 --- a/src/webR/webr-main.ts +++ b/src/webR/webr-main.ts @@ -466,18 +466,42 @@ export class WebR { return this.globalShelter.evalR(code, options); } + /** + * Evaluate the given R code, returning a promise for no return data. + * @param {string} code The R code to evaluate. + * @param {EvalROptions} [options] Options for the execution environment. + * @returns {Promise} A promise which fires when the R code completes, but returns no data. + */ async evalRVoid(code: string, options?: EvalROptions) { return this.evalRRaw(code, 'void', options); } + /** + * Evaluate the given R code, returning a promise for a boolean value. If the returned R value is not a boolean, an error will be thrown. + * @param {string} code The R code to evaluate. + * @param {EvalROptions} [options] Options for the execution environment. + * @returns {Promise} The result of the computation. + */ async evalRBoolean(code: string, options?: EvalROptions) { return this.evalRRaw(code, 'boolean', options); } + /** + * Evaluate the given R code, returning a promise for a number. If the returned R value is not a number, an error will be thrown. + * @param {string} code The R code to evaluate. + * @param {EvalROptions} [options] Options for the execution environment. + * @returns {Promise} The result of the computation. + */ async evalRNumber(code: string, options?: EvalROptions) { return this.evalRRaw(code, 'number', options); } + /** + * Evaluate the given R code, returning a promise for a string. If the returned R value is not a string, an error will be thrown. + * @param {string} code The R code to evaluate. + * @param {EvalROptions} [options] Options for the execution environment. + * @returns {Promise} The result of the computation. + */ async evalRString(code: string, options?: EvalROptions) { return this.evalRRaw(code, 'string', options); }