Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions src/webR/webr-main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<undefined>} A promise which fires when the R code completes, but returns no data.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* @returns {Promise<undefined>} A promise which fires when the R code completes, but returns no data.
* @returns {Promise<void>} 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<unknown>} The result of the computation.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* @returns {Promise<unknown>} The result of the computation.
* @returns {Promise<boolean>} 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<unknown>} The result of the computation.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* @returns {Promise<unknown>} The result of the computation.
* @returns {Promise<number>} 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<unknown>} The result of the computation.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* @returns {Promise<unknown>} The result of the computation.
* @returns {Promise<string>} The result of the computation.

*/
async evalRString(code: string, options?: EvalROptions) {
return this.evalRRaw(code, 'string', options);
}
Expand Down