summaryrefslogtreecommitdiff
path: root/ext/console/README.md
blob: fab5f8536c5f049ee73979acde29f013a48e8138 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# deno_console

**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