diff options
| author | Trevor Manz <trevor.j.manz@gmail.com> | 2023-10-06 17:26:11 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-10-06 21:26:11 +0000 |
| commit | 48bb3b2b0f519077e1a454034fbbe79d9db23c4a (patch) | |
| tree | 4caaa16c482ecae97cd7f8e22030a90a0eea0174 /cli/tests/testdata | |
| parent | ceecd8c495619284eee5763c1adb4afba345dceb (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/tests/testdata')
| -rw-r--r-- | cli/tests/testdata/jupyter/integration_test.ipynb | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/cli/tests/testdata/jupyter/integration_test.ipynb b/cli/tests/testdata/jupyter/integration_test.ipynb index 25d55e88c..b8aed651c 100644 --- a/cli/tests/testdata/jupyter/integration_test.ipynb +++ b/cli/tests/testdata/jupyter/integration_test.ipynb @@ -827,6 +827,43 @@ "let sc = new SuperColor()\n", "sc" ] + }, + { + "cell_type": "code", + "execution_count": 27, + "id": "c1296291-a3e8-457b-8329-6cc58a1e528a", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "<div style=\"width: 32px; height: 32px; background-color: #239814\" />" + ] + }, + "execution_count": 27, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "class SuperColorAsync {\n", + " constructor() {\n", + " this.color = \"#239814\"\n", + " }\n", + " hex() {\n", + " return this.color\n", + " }\n", + " \n", + " async [Symbol.for(\"Jupyter.display\")]() {\n", + " return {\n", + " \"text/html\": `<div style=\"width: 32px; height: 32px; background-color: ${this.hex()}\" />`\n", + " }\n", + " }\n", + "}\n", + "\n", + "let sc = new SuperColorAsync()\n", + "sc" + ] } ], "metadata": { |
