mirror of
https://github.com/denoland/deno.git
synced 2025-10-02 07:01:16 +00:00
docs(cli/dts): fix plugin example (#10647)
This commit is contained in:
parent
218ba031f0
commit
736ff290b8
2 changed files with 19 additions and 4 deletions
21
cli/dts/lib.deno.unstable.d.ts
vendored
21
cli/dts/lib.deno.unstable.d.ts
vendored
|
@ -133,10 +133,25 @@ declare namespace Deno {
|
|||
* Open and initialize a plugin.
|
||||
*
|
||||
* ```ts
|
||||
* import { assert } from "https://deno.land/std/testing/asserts.ts";
|
||||
* const rid = Deno.openPlugin("./path/to/some/plugin.so");
|
||||
* const opId = Deno.core.ops()["some_op"];
|
||||
* const response = Deno.core.dispatch(opId, new Uint8Array([1,2,3,4]));
|
||||
* console.log(`Response from plugin ${response}`);
|
||||
*
|
||||
* // The Deno.core namespace is needed to interact with plugins, but this is
|
||||
* // internal so we use ts-ignore to skip type checking these calls.
|
||||
* // @ts-ignore
|
||||
* const {
|
||||
* op_test_sync,
|
||||
* op_test_async,
|
||||
* } = Deno.core.ops();
|
||||
*
|
||||
* assert(op_test_sync);
|
||||
* assert(op_test_async);
|
||||
*
|
||||
* // @ts-ignore
|
||||
* const result = Deno.core.opSync("op_test_sync");
|
||||
*
|
||||
* // @ts-ignore
|
||||
* const result = await Deno.core.opAsync("op_test_sync");
|
||||
* ```
|
||||
*
|
||||
* Requires `allow-plugin` permission.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue