summaryrefslogtreecommitdiff
path: root/ext/console
diff options
context:
space:
mode:
authorRichard Carson <Rscarson@rogers.com>2024-06-17 18:07:48 -0400
committerGitHub <noreply@github.com>2024-06-18 00:07:48 +0200
commit257f0273250087bd5080430fe4c780b208d7986c (patch)
treee488fddde3f9eb095700e8e921385e8a71a202be /ext/console
parent5dec3fd4b75a59574e5aeed4e927d8e3e0c1c683 (diff)
docs: Add documentation to a subset of available extensions (#24138)
I was able to use my experience with some of the Deno extensions to flesh out their documentation a bit I've provided docs for the following: - web - fetch - net - webidl - url - io - crypto - console --------- Signed-off-by: Richard Carson <Rscarson@rogers.com>
Diffstat (limited to 'ext/console')
-rw-r--r--ext/console/README.md28
1 files changed, 27 insertions, 1 deletions
diff --git a/ext/console/README.md b/ext/console/README.md
index 2f8fb448a..fab5f8536 100644
--- a/ext/console/README.md
+++ b/ext/console/README.md
@@ -1,5 +1,31 @@
# deno_console
-This crate implements the Console API.
+**This crate implements the Console API.**
Spec: https://console.spec.whatwg.org/
+
+## Usage Example
+
+From javascript, include the extension's source, and assign a console to the
+global scope:
+
+```javascript
+import * as console from "ext:deno_console/01_console.js";
+Object.defineProperty(globalThis, "console", {
+ value: new console.Console((msg, level) =>
+ globalThis.Deno.core.print(msg, level > 1)
+ ),
+ enumerable: false,
+ configurable: true,
+ writable: true,
+});
+```
+
+Then from rust, provide `deno_console::deno_console::init_ops_and_esm()` in the
+`extensions` field of your `RuntimeOptions`
+
+## Provided ops
+
+Following ops are provided, which can be accessed through `Deno.ops`:
+
+- op_preview_entries