Skip to content

Commit 95b43ba

Browse files
Add inline documentation for evalR methods (#571)
* Add inline docs for evalR methods * Apply suggestions from code review --------- Co-authored-by: George Stagg <[email protected]>
1 parent 995fa5a commit 95b43ba

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

src/webR/webr-main.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -486,18 +486,42 @@ export class WebR {
486486
return this.globalShelter.evalR(code, options);
487487
}
488488

489+
/**
490+
* Evaluate the given R code, returning a promise for no return data.
491+
* @param {string} code The R code to evaluate.
492+
* @param {EvalROptions} [options] Options for the execution environment.
493+
* @returns {Promise<void>} A promise which fires when the R code completes, but returns no data.
494+
*/
489495
async evalRVoid(code: string, options?: EvalROptions) {
490496
return this.evalRRaw(code, 'void', options);
491497
}
492498

499+
/**
500+
* 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.
501+
* @param {string} code The R code to evaluate.
502+
* @param {EvalROptions} [options] Options for the execution environment.
503+
* @returns {Promise<boolean>} The result of the computation.
504+
*/
493505
async evalRBoolean(code: string, options?: EvalROptions) {
494506
return this.evalRRaw(code, 'boolean', options);
495507
}
496508

509+
/**
510+
* 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.
511+
* @param {string} code The R code to evaluate.
512+
* @param {EvalROptions} [options] Options for the execution environment.
513+
* @returns {Promise<number>} The result of the computation.
514+
*/
497515
async evalRNumber(code: string, options?: EvalROptions) {
498516
return this.evalRRaw(code, 'number', options);
499517
}
500518

519+
/**
520+
* 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.
521+
* @param {string} code The R code to evaluate.
522+
* @param {EvalROptions} [options] Options for the execution environment.
523+
* @returns {Promise<string>} The result of the computation.
524+
*/
501525
async evalRString(code: string, options?: EvalROptions) {
502526
return this.evalRRaw(code, 'string', options);
503527
}

0 commit comments

Comments
 (0)