Skip to content

Commit

Permalink
docs: update permissions examples
Browse files Browse the repository at this point in the history
  • Loading branch information
kt3k committed Oct 27, 2019
1 parent 094619f commit 3fbe787
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions std/manual.md
Original file line number Diff line number Diff line change
Expand Up @@ -353,18 +353,19 @@ Sometimes a program may want to revoke previously granted permissions. When a
program, at a later stage, needs those permissions, it will fail.

```ts
const { permissions, revokePermission, open, remove } = Deno;
const { permissions, open, remove } = Deno;

// lookup a permission
if (!permissions().write) {
const status = await permissions.query({ name: "write" });
if (status.state !== "granted") {
throw new Error("need write permission");
}

const log = await open("request.log", "a+");

// revoke some permissions
revokePermission("read");
revokePermission("write");
await permissions.revoke({ name: "read" });
await permissions.revoke({ name: "write" });

// use the log file
const encoder = new TextEncoder();
Expand Down

0 comments on commit 3fbe787

Please sign in to comment.