diff options
author | Yoshiya Hinosawa <stibium121@gmail.com> | 2019-10-28 00:22:53 +0900 |
---|---|---|
committer | Ry Dahl <ry@tinyclouds.org> | 2019-10-27 11:22:53 -0400 |
commit | efd7e78af3fc086dfdec51738905665d38d08eb4 (patch) | |
tree | bb921f7d960f33c6d4d13c043a7a45ebe74290ba /std/manual.md | |
parent | 2598f9c68d8983934c73c135c9d277b33c98e333 (diff) |
Use web standard Permissions API (#3200)
Diffstat (limited to 'std/manual.md')
-rw-r--r-- | std/manual.md | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/std/manual.md b/std/manual.md index 6da2d0ec2..70ecdc9ac 100644 --- a/std/manual.md +++ b/std/manual.md @@ -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(); |