Skip to content

Commit

Permalink
Use web standard Permissions API (denoland/deno#3200)
Browse files Browse the repository at this point in the history
  • Loading branch information
kt3k authored and caspervonb committed Jan 31, 2021
1 parent e510087 commit 279944e
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions 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 279944e

Please sign in to comment.