diff options
Diffstat (limited to 'cli/tsc')
-rw-r--r-- | cli/tsc/dts/lib.deno.ns.d.ts | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/cli/tsc/dts/lib.deno.ns.d.ts b/cli/tsc/dts/lib.deno.ns.d.ts index b6add6e4b..84655a5f3 100644 --- a/cli/tsc/dts/lib.deno.ns.d.ts +++ b/cli/tsc/dts/lib.deno.ns.d.ts @@ -4279,6 +4279,20 @@ declare namespace Deno { */ query(desc: PermissionDescriptor): Promise<PermissionStatus>; + /** Returns the current status of a permission. + * + * Note, if the permission is already granted, `request()` will not prompt + * the user again, therefore `querySync()` is only necessary if you are going + * to react differently existing permissions without wanting to modify them + * or prompt the user to modify them. + * + * ```ts + * const status = Deno.permissions.querySync({ name: "read", path: "/etc" }); + * console.log(status.state); + * ``` + */ + querySync(desc: PermissionDescriptor): PermissionStatus; + /** Revokes a permission, and resolves to the state of the permission. * * ```ts @@ -4290,6 +4304,17 @@ declare namespace Deno { */ revoke(desc: PermissionDescriptor): Promise<PermissionStatus>; + /** Revokes a permission, and returns the state of the permission. + * + * ```ts + * import { assert } from "https://deno.land/std/testing/asserts.ts"; + * + * const status = Deno.permissions.revokeSync({ name: "run" }); + * assert(status.state !== "granted") + * ``` + */ + revokeSync(desc: PermissionDescriptor): PermissionStatus; + /** Requests the permission, and resolves to the state of the permission. * * If the permission is already granted, the user will not be prompted to @@ -4305,6 +4330,23 @@ declare namespace Deno { * ``` */ request(desc: PermissionDescriptor): Promise<PermissionStatus>; + + + /** Requests the permission, and returns the state of the permission. + * + * If the permission is already granted, the user will not be prompted to + * grant the permission again. + * + * ```ts + * const status = Deno.permissions.requestSync({ name: "env" }); + * if (status.state === "granted") { + * console.log("'env' permission is granted."); + * } else { + * console.log("'env' permission is denied."); + * } + * ``` + */ + requestSync(desc: PermissionDescriptor): PermissionStatus; } /** Deno's permission management API. @@ -4335,6 +4377,11 @@ declare namespace Deno { * const status = await Deno.permissions.query({ name: "read", path: "/etc" }); * console.log(status.state); * ``` + * + * ```ts + * const status = Deno.permissions.querySync({ name: "read", path: "/etc" }); + * console.log(status.state); + * ``` * * ### Revoking * @@ -4344,6 +4391,13 @@ declare namespace Deno { * const status = await Deno.permissions.revoke({ name: "run" }); * assert(status.state !== "granted") * ``` + * + * ```ts + * import { assert } from "https://deno.land/std/testing/asserts.ts"; + * + * const status = Deno.permissions.revokeSync({ name: "run" }); + * assert(status.state !== "granted") + * ``` * * ### Requesting * @@ -4355,6 +4409,15 @@ declare namespace Deno { * console.log("'env' permission is denied."); * } * ``` + * + * ```ts + * const status = Deno.permissions.requestSync({ name: "env" }); + * if (status.state === "granted") { + * console.log("'env' permission is granted."); + * } else { + * console.log("'env' permission is denied."); + * } + * ``` * * @category Permissions */ |