Skip to content

Commit

Permalink
Attempt JS object RDataFrame conversion before RList
Browse files Browse the repository at this point in the history
  • Loading branch information
georgestagg committed Jul 28, 2024
1 parent 0bca2d4 commit 7387adb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion _extensions/live/resources/live-runtime.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 10 additions & 4 deletions live-runtime/src/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,15 @@ export class WebREnvironmentManager {

const shelter = await this.shelter;
if (value && value.constructor === Object) {
value = await new shelter.RList(value);
try {
value = await new shelter.RObject(value);
} catch (_e) {
const e = _e as Error;
if (!e.message.includes("Can't construct `data.frame`")) {
throw e;
}
value = await new shelter.RList(value);
}
} else if (value && value.constructor === Array) {
try {
value = await new shelter.RObject(value);
Expand All @@ -36,9 +44,7 @@ export class WebREnvironmentManager {
throw e;
}
value = await Promise.all(value.map((v) => {
return new shelter.RList(v).then((obj) => {
return obj;
})
return new shelter.RList(v);
}));
}
}
Expand Down

0 comments on commit 7387adb

Please sign in to comment.