summaryrefslogtreecommitdiff
path: root/cli/tools/jupyter/server.rs
diff options
context:
space:
mode:
authorTrevor Manz <trevor.j.manz@gmail.com>2023-10-06 17:26:11 -0400
committerGitHub <noreply@github.com>2023-10-06 21:26:11 +0000
commit48bb3b2b0f519077e1a454034fbbe79d9db23c4a (patch)
tree4caaa16c482ecae97cd7f8e22030a90a0eea0174 /cli/tools/jupyter/server.rs
parentceecd8c495619284eee5763c1adb4afba345dceb (diff)
feat(unstable): Await return from `Jupyter.display` (#20807)
Allows `Jupyter.display` to return a promise. Example: ```javascript class WikiPage { constructor(public name) {} async [Symbol.for("Jupyter.display")]() { let response = await fetch("https://en.wikipedia.org/wiki/" + this.name); return { "text/html": await response.text() } } } new WikiPage("Deno_(software)") ```
Diffstat (limited to 'cli/tools/jupyter/server.rs')
-rw-r--r--cli/tools/jupyter/server.rs6
1 files changed, 3 insertions, 3 deletions
diff --git a/cli/tools/jupyter/server.rs b/cli/tools/jupyter/server.rs
index 391d202fd..2c7bea9d2 100644
--- a/cli/tools/jupyter/server.rs
+++ b/cli/tools/jupyter/server.rs
@@ -551,13 +551,13 @@ async fn get_jupyter_display(
.post_message_with_event_loop(
"Runtime.callFunctionOn",
Some(json!({
- "functionDeclaration": r#"function (object) {
+ "functionDeclaration": r#"async function (object) {
if (typeof object[Symbol.for("Jupyter.display")] !== "function") {
return null;
}
-
+
try {
- const representation = object[Symbol.for("Jupyter.display")]();
+ const representation = await object[Symbol.for("Jupyter.display")]();
return JSON.stringify(representation);
} catch {
return null;