mirror of
https://github.com/denoland/deno.git
synced 2025-07-24 05:35:33 +00:00
Fix formatting of example code in typescript declaration files (#5475)
This commit is contained in:
parent
acc821c2be
commit
bfd4baf2d3
3 changed files with 721 additions and 478 deletions
818
cli/js/lib.deno.ns.d.ts
vendored
818
cli/js/lib.deno.ns.d.ts
vendored
File diff suppressed because it is too large
Load diff
137
cli/js/lib.deno.shared_globals.d.ts
vendored
137
cli/js/lib.deno.shared_globals.d.ts
vendored
|
@ -1005,37 +1005,47 @@ declare class TextEncoder {
|
||||||
interface URLSearchParams {
|
interface URLSearchParams {
|
||||||
/** Appends a specified key/value pair as a new search parameter.
|
/** Appends a specified key/value pair as a new search parameter.
|
||||||
*
|
*
|
||||||
* let searchParams = new URLSearchParams();
|
* ```ts
|
||||||
* searchParams.append('name', 'first');
|
* let searchParams = new URLSearchParams();
|
||||||
* searchParams.append('name', 'second');
|
* searchParams.append('name', 'first');
|
||||||
|
* searchParams.append('name', 'second');
|
||||||
|
* ```
|
||||||
*/
|
*/
|
||||||
append(name: string, value: string): void;
|
append(name: string, value: string): void;
|
||||||
|
|
||||||
/** Deletes the given search parameter and its associated value,
|
/** Deletes the given search parameter and its associated value,
|
||||||
* from the list of all search parameters.
|
* from the list of all search parameters.
|
||||||
*
|
*
|
||||||
* let searchParams = new URLSearchParams([['name', 'value']]);
|
* ```ts
|
||||||
* searchParams.delete('name');
|
* let searchParams = new URLSearchParams([['name', 'value']]);
|
||||||
|
* searchParams.delete('name');
|
||||||
|
* ```
|
||||||
*/
|
*/
|
||||||
delete(name: string): void;
|
delete(name: string): void;
|
||||||
|
|
||||||
/** Returns all the values associated with a given search parameter
|
/** Returns all the values associated with a given search parameter
|
||||||
* as an array.
|
* as an array.
|
||||||
*
|
*
|
||||||
* searchParams.getAll('name');
|
* ```ts
|
||||||
|
* searchParams.getAll('name');
|
||||||
|
* ```
|
||||||
*/
|
*/
|
||||||
getAll(name: string): string[];
|
getAll(name: string): string[];
|
||||||
|
|
||||||
/** Returns the first value associated to the given search parameter.
|
/** Returns the first value associated to the given search parameter.
|
||||||
*
|
*
|
||||||
* searchParams.get('name');
|
* ```ts
|
||||||
|
* searchParams.get('name');
|
||||||
|
* ```
|
||||||
*/
|
*/
|
||||||
get(name: string): string | null;
|
get(name: string): string | null;
|
||||||
|
|
||||||
/** Returns a Boolean that indicates whether a parameter with the
|
/** Returns a Boolean that indicates whether a parameter with the
|
||||||
* specified name exists.
|
* specified name exists.
|
||||||
*
|
*
|
||||||
* searchParams.has('name');
|
* ```ts
|
||||||
|
* searchParams.has('name');
|
||||||
|
* ```
|
||||||
*/
|
*/
|
||||||
has(name: string): boolean;
|
has(name: string): boolean;
|
||||||
|
|
||||||
|
@ -1044,7 +1054,9 @@ interface URLSearchParams {
|
||||||
* deletes the others. If the search parameter doesn't exist, this
|
* deletes the others. If the search parameter doesn't exist, this
|
||||||
* method creates it.
|
* method creates it.
|
||||||
*
|
*
|
||||||
* searchParams.set('name', 'value');
|
* ```ts
|
||||||
|
* searchParams.set('name', 'value');
|
||||||
|
* ```
|
||||||
*/
|
*/
|
||||||
set(name: string, value: string): void;
|
set(name: string, value: string): void;
|
||||||
|
|
||||||
|
@ -1052,7 +1064,9 @@ interface URLSearchParams {
|
||||||
* return undefined. The sort order is according to Unicode code
|
* return undefined. The sort order is according to Unicode code
|
||||||
* points of the keys.
|
* points of the keys.
|
||||||
*
|
*
|
||||||
* searchParams.sort();
|
* ```ts
|
||||||
|
* searchParams.sort();
|
||||||
|
* ```
|
||||||
*/
|
*/
|
||||||
sort(): void;
|
sort(): void;
|
||||||
|
|
||||||
|
@ -1060,10 +1074,12 @@ interface URLSearchParams {
|
||||||
* place and return undefined. Optionally accepts an object to use
|
* place and return undefined. Optionally accepts an object to use
|
||||||
* as this when executing callback as second argument.
|
* as this when executing callback as second argument.
|
||||||
*
|
*
|
||||||
* const params = new URLSearchParams([["a", "b"], ["c", "d"]]);
|
* ```ts
|
||||||
* params.forEach((value, key, parent) => {
|
* const params = new URLSearchParams([["a", "b"], ["c", "d"]]);
|
||||||
* console.log(value, key, parent);
|
* params.forEach((value, key, parent) => {
|
||||||
* });
|
* console.log(value, key, parent);
|
||||||
|
* });
|
||||||
|
* ```
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
forEach(
|
forEach(
|
||||||
|
@ -1074,46 +1090,56 @@ interface URLSearchParams {
|
||||||
/** Returns an iterator allowing to go through all keys contained
|
/** Returns an iterator allowing to go through all keys contained
|
||||||
* in this object.
|
* in this object.
|
||||||
*
|
*
|
||||||
* const params = new URLSearchParams([["a", "b"], ["c", "d"]]);
|
* ```ts
|
||||||
* for (const key of params.keys()) {
|
* const params = new URLSearchParams([["a", "b"], ["c", "d"]]);
|
||||||
* console.log(key);
|
* for (const key of params.keys()) {
|
||||||
* }
|
* console.log(key);
|
||||||
|
* }
|
||||||
|
* ```
|
||||||
*/
|
*/
|
||||||
keys(): IterableIterator<string>;
|
keys(): IterableIterator<string>;
|
||||||
|
|
||||||
/** Returns an iterator allowing to go through all values contained
|
/** Returns an iterator allowing to go through all values contained
|
||||||
* in this object.
|
* in this object.
|
||||||
*
|
*
|
||||||
* const params = new URLSearchParams([["a", "b"], ["c", "d"]]);
|
* ```ts
|
||||||
* for (const value of params.values()) {
|
* const params = new URLSearchParams([["a", "b"], ["c", "d"]]);
|
||||||
* console.log(value);
|
* for (const value of params.values()) {
|
||||||
* }
|
* console.log(value);
|
||||||
|
* }
|
||||||
|
* ```
|
||||||
*/
|
*/
|
||||||
values(): IterableIterator<string>;
|
values(): IterableIterator<string>;
|
||||||
|
|
||||||
/** Returns an iterator allowing to go through all key/value
|
/** Returns an iterator allowing to go through all key/value
|
||||||
* pairs contained in this object.
|
* pairs contained in this object.
|
||||||
*
|
*
|
||||||
* const params = new URLSearchParams([["a", "b"], ["c", "d"]]);
|
* ```ts
|
||||||
* for (const [key, value] of params.entries()) {
|
* const params = new URLSearchParams([["a", "b"], ["c", "d"]]);
|
||||||
* console.log(key, value);
|
* for (const [key, value] of params.entries()) {
|
||||||
* }
|
* console.log(key, value);
|
||||||
|
* }
|
||||||
|
* ```
|
||||||
*/
|
*/
|
||||||
entries(): IterableIterator<[string, string]>;
|
entries(): IterableIterator<[string, string]>;
|
||||||
|
|
||||||
/** Returns an iterator allowing to go through all key/value
|
/** Returns an iterator allowing to go through all key/value
|
||||||
* pairs contained in this object.
|
* pairs contained in this object.
|
||||||
*
|
*
|
||||||
* const params = new URLSearchParams([["a", "b"], ["c", "d"]]);
|
* ```ts
|
||||||
* for (const [key, value] of params) {
|
* const params = new URLSearchParams([["a", "b"], ["c", "d"]]);
|
||||||
* console.log(key, value);
|
* for (const [key, value] of params) {
|
||||||
* }
|
* console.log(key, value);
|
||||||
|
* }
|
||||||
|
* ```
|
||||||
*/
|
*/
|
||||||
[Symbol.iterator](): IterableIterator<[string, string]>;
|
[Symbol.iterator](): IterableIterator<[string, string]>;
|
||||||
|
|
||||||
/** Returns a query string suitable for use in a URL.
|
/** Returns a query string suitable for use in a URL.
|
||||||
*
|
*
|
||||||
* searchParams.toString();
|
* ```ts
|
||||||
|
* searchParams.toString();
|
||||||
|
* ```
|
||||||
*/
|
*/
|
||||||
toString(): string;
|
toString(): string;
|
||||||
}
|
}
|
||||||
|
@ -1206,31 +1232,34 @@ declare class Worker extends EventTarget {
|
||||||
* Configurable permissions are on the roadmap to be implemented.
|
* Configurable permissions are on the roadmap to be implemented.
|
||||||
*
|
*
|
||||||
* Example:
|
* Example:
|
||||||
* // mod.ts
|
|
||||||
* const worker = new Worker("./deno_worker.ts", { type: "module", deno: true });
|
|
||||||
* worker.postMessage({ cmd: "readFile", fileName: "./log.txt" });
|
|
||||||
*
|
*
|
||||||
* // deno_worker.ts
|
* ```ts
|
||||||
|
* // mod.ts
|
||||||
|
* const worker = new Worker("./deno_worker.ts", { type: "module", deno: true });
|
||||||
|
* worker.postMessage({ cmd: "readFile", fileName: "./log.txt" });
|
||||||
|
*
|
||||||
|
* // deno_worker.ts
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* self.onmessage = async function (e) {
|
* self.onmessage = async function (e) {
|
||||||
* const { cmd, fileName } = e.data;
|
* const { cmd, fileName } = e.data;
|
||||||
* if (cmd !== "readFile") {
|
* if (cmd !== "readFile") {
|
||||||
* throw new Error("Invalid command");
|
* throw new Error("Invalid command");
|
||||||
* }
|
* }
|
||||||
* const buf = await Deno.readFile(fileName);
|
* const buf = await Deno.readFile(fileName);
|
||||||
* const fileContents = new TextDecoder().decode(buf);
|
* const fileContents = new TextDecoder().decode(buf);
|
||||||
* console.log(fileContents);
|
* console.log(fileContents);
|
||||||
* }
|
* }
|
||||||
|
* ```
|
||||||
*
|
*
|
||||||
* // log.txt
|
* // log.txt
|
||||||
* hello world
|
* hello world
|
||||||
* hello world 2
|
* hello world 2
|
||||||
*
|
*
|
||||||
* // run program
|
* // run program
|
||||||
* $ deno run --allow-read mod.ts
|
* $ deno run --allow-read mod.ts
|
||||||
* hello world
|
* hello world
|
||||||
* hello world2
|
* hello world2
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
deno?: boolean;
|
deno?: boolean;
|
||||||
|
@ -1246,8 +1275,10 @@ declare namespace performance {
|
||||||
*
|
*
|
||||||
* Use the flag --allow-hrtime return a precise value.
|
* Use the flag --allow-hrtime return a precise value.
|
||||||
*
|
*
|
||||||
* const t = performance.now();
|
* ```ts
|
||||||
* console.log(`${t} ms since start!`);
|
* const t = performance.now();
|
||||||
|
* console.log(`${t} ms since start!`);
|
||||||
|
* ```
|
||||||
*/
|
*/
|
||||||
export function now(): number;
|
export function now(): number;
|
||||||
}
|
}
|
||||||
|
|
244
cli/js/lib.deno.unstable.d.ts
vendored
244
cli/js/lib.deno.unstable.d.ts
vendored
|
@ -11,9 +11,11 @@ declare namespace Deno {
|
||||||
* Retrieve the process umask. If `mask` is provided, sets the process umask.
|
* Retrieve the process umask. If `mask` is provided, sets the process umask.
|
||||||
* This call always returns what the umask was before the call.
|
* This call always returns what the umask was before the call.
|
||||||
*
|
*
|
||||||
* console.log(Deno.umask()); // e.g. 18 (0o022)
|
* ```ts
|
||||||
* const prevUmaskValue = Deno.umask(0o077); // e.g. 18 (0o022)
|
* console.log(Deno.umask()); // e.g. 18 (0o022)
|
||||||
* console.log(Deno.umask()); // e.g. 63 (0o077)
|
* const prevUmaskValue = Deno.umask(0o077); // e.g. 18 (0o022)
|
||||||
|
* console.log(Deno.umask()); // e.g. 63 (0o077)
|
||||||
|
* ```
|
||||||
*
|
*
|
||||||
* NOTE: This API is not implemented on Windows
|
* NOTE: This API is not implemented on Windows
|
||||||
*/
|
*/
|
||||||
|
@ -21,7 +23,9 @@ declare namespace Deno {
|
||||||
|
|
||||||
/** Synchronously creates `newpath` as a hard link to `oldpath`.
|
/** Synchronously creates `newpath` as a hard link to `oldpath`.
|
||||||
*
|
*
|
||||||
* Deno.linkSync("old/name", "new/name");
|
* ```ts
|
||||||
|
* Deno.linkSync("old/name", "new/name");
|
||||||
|
* ```
|
||||||
*
|
*
|
||||||
* Requires `allow-read` and `allow-write` permissions. */
|
* Requires `allow-read` and `allow-write` permissions. */
|
||||||
export function linkSync(oldpath: string, newpath: string): void;
|
export function linkSync(oldpath: string, newpath: string): void;
|
||||||
|
@ -30,7 +34,9 @@ declare namespace Deno {
|
||||||
*
|
*
|
||||||
* **UNSTABLE**: needs security review.
|
* **UNSTABLE**: needs security review.
|
||||||
*
|
*
|
||||||
* await Deno.link("old/name", "new/name");
|
* ```ts
|
||||||
|
* await Deno.link("old/name", "new/name");
|
||||||
|
* ```
|
||||||
*
|
*
|
||||||
* Requires `allow-read` and `allow-write` permissions. */
|
* Requires `allow-read` and `allow-write` permissions. */
|
||||||
export function link(oldpath: string, newpath: string): Promise<void>;
|
export function link(oldpath: string, newpath: string): Promise<void>;
|
||||||
|
@ -46,7 +52,9 @@ declare namespace Deno {
|
||||||
*
|
*
|
||||||
* NOTE: This function is not yet implemented on Windows.
|
* NOTE: This function is not yet implemented on Windows.
|
||||||
*
|
*
|
||||||
* Deno.symlinkSync("old/name", "new/name");
|
* ```ts
|
||||||
|
* Deno.symlinkSync("old/name", "new/name");
|
||||||
|
* ```
|
||||||
*
|
*
|
||||||
* Requires `allow-read` and `allow-write` permissions. */
|
* Requires `allow-read` and `allow-write` permissions. */
|
||||||
export function symlinkSync(
|
export function symlinkSync(
|
||||||
|
@ -66,7 +74,9 @@ declare namespace Deno {
|
||||||
*
|
*
|
||||||
* NOTE: This function is not yet implemented on Windows.
|
* NOTE: This function is not yet implemented on Windows.
|
||||||
*
|
*
|
||||||
* await Deno.symlink("old/name", "new/name");
|
* ```ts
|
||||||
|
* await Deno.symlink("old/name", "new/name");
|
||||||
|
* ```
|
||||||
*
|
*
|
||||||
* Requires `allow-read` and `allow-write` permissions. */
|
* Requires `allow-read` and `allow-write` permissions. */
|
||||||
export function symlink(
|
export function symlink(
|
||||||
|
@ -100,7 +110,9 @@ declare namespace Deno {
|
||||||
*
|
*
|
||||||
* Returns the user and platform specific directories.
|
* Returns the user and platform specific directories.
|
||||||
*
|
*
|
||||||
* const homeDirectory = Deno.dir("home");
|
* ```ts
|
||||||
|
* const homeDirectory = Deno.dir("home");
|
||||||
|
* ```
|
||||||
*
|
*
|
||||||
* Requires `allow-env` permission.
|
* Requires `allow-env` permission.
|
||||||
*
|
*
|
||||||
|
@ -248,7 +260,9 @@ declare namespace Deno {
|
||||||
* is no load. On Windows, the three values are always the same and represent
|
* is no load. On Windows, the three values are always the same and represent
|
||||||
* the current load, not the 1, 5 and 15 minute load averages.
|
* the current load, not the 1, 5 and 15 minute load averages.
|
||||||
*
|
*
|
||||||
* console.log(Deno.loadavg()); // e.g. [ 0.71, 0.44, 0.44 ]
|
* ```ts
|
||||||
|
* console.log(Deno.loadavg()); // e.g. [ 0.71, 0.44, 0.44 ]
|
||||||
|
* ```
|
||||||
*
|
*
|
||||||
* Requires `allow-env` permission.
|
* Requires `allow-env` permission.
|
||||||
*
|
*
|
||||||
|
@ -259,7 +273,9 @@ declare namespace Deno {
|
||||||
|
|
||||||
/** Returns the release version of the Operating System.
|
/** Returns the release version of the Operating System.
|
||||||
*
|
*
|
||||||
* console.log(Deno.osRelease());
|
* ```ts
|
||||||
|
* console.log(Deno.osRelease());
|
||||||
|
* ```
|
||||||
*
|
*
|
||||||
* Requires `allow-env` permission.
|
* Requires `allow-env` permission.
|
||||||
*
|
*
|
||||||
|
@ -272,10 +288,12 @@ declare namespace Deno {
|
||||||
*
|
*
|
||||||
* Open and initialize a plugin.
|
* Open and initialize a plugin.
|
||||||
*
|
*
|
||||||
* const rid = Deno.openPlugin("./path/to/some/plugin.so");
|
* ```ts
|
||||||
* const opId = Deno.core.ops()["some_op"];
|
* const rid = Deno.openPlugin("./path/to/some/plugin.so");
|
||||||
* const response = Deno.core.dispatch(opId, new Uint8Array([1,2,3,4]));
|
* const opId = Deno.core.ops()["some_op"];
|
||||||
* console.log(`Response from plugin ${response}`);
|
* const response = Deno.core.dispatch(opId, new Uint8Array([1,2,3,4]));
|
||||||
|
* console.log(`Response from plugin ${response}`);
|
||||||
|
* ```
|
||||||
*
|
*
|
||||||
* Requires `allow-plugin` permission.
|
* Requires `allow-plugin` permission.
|
||||||
*
|
*
|
||||||
|
@ -340,9 +358,11 @@ declare namespace Deno {
|
||||||
* Format an array of diagnostic items and return them as a single string in a
|
* Format an array of diagnostic items and return them as a single string in a
|
||||||
* user friendly format.
|
* user friendly format.
|
||||||
*
|
*
|
||||||
* const [diagnostics, result] = Deno.compile("file_with_compile_issues.ts");
|
* ```ts
|
||||||
* console.table(diagnostics); // Prints raw diagnostic data
|
* const [diagnostics, result] = Deno.compile("file_with_compile_issues.ts");
|
||||||
* console.log(Deno.formatDiagnostics(diagnostics)); // User friendly output of diagnostics
|
* console.table(diagnostics); // Prints raw diagnostic data
|
||||||
|
* console.log(Deno.formatDiagnostics(diagnostics)); // User friendly output of diagnostics
|
||||||
|
* ```
|
||||||
*
|
*
|
||||||
* @param items An array of diagnostic items to format
|
* @param items An array of diagnostic items to format
|
||||||
*/
|
*/
|
||||||
|
@ -541,13 +561,15 @@ declare namespace Deno {
|
||||||
* irrespective of if sources are provided on the call. Like other Deno
|
* irrespective of if sources are provided on the call. Like other Deno
|
||||||
* modules, there is no "magical" resolution. For example:
|
* modules, there is no "magical" resolution. For example:
|
||||||
*
|
*
|
||||||
* Deno.compile(
|
* ```ts
|
||||||
* "./foo.js",
|
* Deno.compile(
|
||||||
* undefined,
|
* "./foo.js",
|
||||||
* {
|
* undefined,
|
||||||
* types: [ "./foo.d.ts", "https://deno.land/x/example/types.d.ts" ]
|
* {
|
||||||
* }
|
* types: [ "./foo.d.ts", "https://deno.land/x/example/types.d.ts" ]
|
||||||
* );
|
* }
|
||||||
|
* );
|
||||||
|
* ```
|
||||||
*/
|
*/
|
||||||
types?: string[];
|
types?: string[];
|
||||||
}
|
}
|
||||||
|
@ -569,9 +591,11 @@ declare namespace Deno {
|
||||||
* type checking and validation, it effectively "strips" the types from the
|
* type checking and validation, it effectively "strips" the types from the
|
||||||
* file.
|
* file.
|
||||||
*
|
*
|
||||||
* const results = await Deno.transpileOnly({
|
* ```ts
|
||||||
* "foo.ts": `const foo: string = "foo";`
|
* const results = await Deno.transpileOnly({
|
||||||
* });
|
* "foo.ts": `const foo: string = "foo";`
|
||||||
|
* });
|
||||||
|
* ```
|
||||||
*
|
*
|
||||||
* @param sources A map where the key is the filename and the value is the text
|
* @param sources A map where the key is the filename and the value is the text
|
||||||
* to transpile. The filename is only used in the transpile and
|
* to transpile. The filename is only used in the transpile and
|
||||||
|
@ -598,12 +622,14 @@ declare namespace Deno {
|
||||||
* the key is the module name and the value is the content. The extension of
|
* the key is the module name and the value is the content. The extension of
|
||||||
* the module name will be used to determine the media type of the module.
|
* the module name will be used to determine the media type of the module.
|
||||||
*
|
*
|
||||||
* const [ maybeDiagnostics1, output1 ] = await Deno.compile("foo.ts");
|
* ```ts
|
||||||
|
* const [ maybeDiagnostics1, output1 ] = await Deno.compile("foo.ts");
|
||||||
*
|
*
|
||||||
* const [ maybeDiagnostics2, output2 ] = await Deno.compile("/foo.ts", {
|
* const [ maybeDiagnostics2, output2 ] = await Deno.compile("/foo.ts", {
|
||||||
* "/foo.ts": `export * from "./bar.ts";`,
|
* "/foo.ts": `export * from "./bar.ts";`,
|
||||||
* "/bar.ts": `export const bar = "bar";`
|
* "/bar.ts": `export const bar = "bar";`
|
||||||
* });
|
* });
|
||||||
|
* ```
|
||||||
*
|
*
|
||||||
* @param rootName The root name of the module which will be used as the
|
* @param rootName The root name of the module which will be used as the
|
||||||
* "starting point". If no `sources` is specified, Deno will
|
* "starting point". If no `sources` is specified, Deno will
|
||||||
|
@ -638,13 +664,15 @@ declare namespace Deno {
|
||||||
* the key is the module name and the value is the content. The extension of the
|
* the key is the module name and the value is the content. The extension of the
|
||||||
* module name will be used to determine the media type of the module.
|
* module name will be used to determine the media type of the module.
|
||||||
*
|
*
|
||||||
* // equivalent to "deno bundle foo.ts" from the command line
|
* ```ts
|
||||||
* const [ maybeDiagnostics1, output1 ] = await Deno.bundle("foo.ts");
|
* // equivalent to "deno bundle foo.ts" from the command line
|
||||||
|
* const [ maybeDiagnostics1, output1 ] = await Deno.bundle("foo.ts");
|
||||||
*
|
*
|
||||||
* const [ maybeDiagnostics2, output2 ] = await Deno.bundle("/foo.ts", {
|
* const [ maybeDiagnostics2, output2 ] = await Deno.bundle("/foo.ts", {
|
||||||
* "/foo.ts": `export * from "./bar.ts";`,
|
* "/foo.ts": `export * from "./bar.ts";`,
|
||||||
* "/bar.ts": `export const bar = "bar";`
|
* "/bar.ts": `export const bar = "bar";`
|
||||||
* });
|
* });
|
||||||
|
* ```
|
||||||
*
|
*
|
||||||
* @param rootName The root name of the module which will be used as the
|
* @param rootName The root name of the module which will be used as the
|
||||||
* "starting point". If no `sources` is specified, Deno will
|
* "starting point". If no `sources` is specified, Deno will
|
||||||
|
@ -691,12 +719,14 @@ declare namespace Deno {
|
||||||
*
|
*
|
||||||
* An example:
|
* An example:
|
||||||
*
|
*
|
||||||
* const orig = Deno.applySourceMap({
|
* ```ts
|
||||||
* fileName: "file://my/module.ts",
|
* const orig = Deno.applySourceMap({
|
||||||
* lineNumber: 5,
|
* fileName: "file://my/module.ts",
|
||||||
* columnNumber: 15
|
* lineNumber: 5,
|
||||||
* });
|
* columnNumber: 15
|
||||||
* console.log(`${orig.filename}:${orig.line}:${orig.column}`);
|
* });
|
||||||
|
* console.log(`${orig.filename}:${orig.line}:${orig.column}`);
|
||||||
|
* ```
|
||||||
*/
|
*/
|
||||||
export function applySourceMap(location: Location): Location;
|
export function applySourceMap(location: Location): Location;
|
||||||
|
|
||||||
|
@ -793,24 +823,30 @@ declare namespace Deno {
|
||||||
* Returns the stream of the given signal number. You can use it as an async
|
* Returns the stream of the given signal number. You can use it as an async
|
||||||
* iterator.
|
* iterator.
|
||||||
*
|
*
|
||||||
* for await (const _ of Deno.signal(Deno.Signal.SIGTERM)) {
|
* ```ts
|
||||||
* console.log("got SIGTERM!");
|
* for await (const _ of Deno.signal(Deno.Signal.SIGTERM)) {
|
||||||
* }
|
* console.log("got SIGTERM!");
|
||||||
|
* }
|
||||||
|
* ```
|
||||||
*
|
*
|
||||||
* You can also use it as a promise. In this case you can only receive the
|
* You can also use it as a promise. In this case you can only receive the
|
||||||
* first one.
|
* first one.
|
||||||
*
|
*
|
||||||
* await Deno.signal(Deno.Signal.SIGTERM);
|
* ```ts
|
||||||
* console.log("SIGTERM received!")
|
* await Deno.signal(Deno.Signal.SIGTERM);
|
||||||
|
* console.log("SIGTERM received!")
|
||||||
|
* ```
|
||||||
*
|
*
|
||||||
* If you want to stop receiving the signals, you can use `.dispose()` method
|
* If you want to stop receiving the signals, you can use `.dispose()` method
|
||||||
* of the signal stream object.
|
* of the signal stream object.
|
||||||
*
|
*
|
||||||
* const sig = Deno.signal(Deno.Signal.SIGTERM);
|
* ```ts
|
||||||
* setTimeout(() => { sig.dispose(); }, 5000);
|
* const sig = Deno.signal(Deno.Signal.SIGTERM);
|
||||||
* for await (const _ of sig) {
|
* setTimeout(() => { sig.dispose(); }, 5000);
|
||||||
* console.log("SIGTERM!")
|
* for await (const _ of sig) {
|
||||||
* }
|
* console.log("SIGTERM!")
|
||||||
|
* }
|
||||||
|
* ```
|
||||||
*
|
*
|
||||||
* The above for-await loop exits after 5 seconds when `sig.dispose()` is
|
* The above for-await loop exits after 5 seconds when `sig.dispose()` is
|
||||||
* called.
|
* called.
|
||||||
|
@ -875,7 +911,9 @@ declare namespace Deno {
|
||||||
* Reading from a TTY device in raw mode is faster than reading from a TTY
|
* Reading from a TTY device in raw mode is faster than reading from a TTY
|
||||||
* device in canonical mode.
|
* device in canonical mode.
|
||||||
*
|
*
|
||||||
* Deno.setRaw(myTTY.rid, true);
|
* ```ts
|
||||||
|
* Deno.setRaw(myTTY.rid, true);
|
||||||
|
* ```
|
||||||
*/
|
*/
|
||||||
export function setRaw(rid: number, mode: boolean): void;
|
export function setRaw(rid: number, mode: boolean): void;
|
||||||
|
|
||||||
|
@ -885,7 +923,9 @@ declare namespace Deno {
|
||||||
* of a file system object referenced by `path`. Given times are either in
|
* of a file system object referenced by `path`. Given times are either in
|
||||||
* seconds (UNIX epoch time) or as `Date` objects.
|
* seconds (UNIX epoch time) or as `Date` objects.
|
||||||
*
|
*
|
||||||
* Deno.utimeSync("myfile.txt", 1556495550, new Date());
|
* ```ts
|
||||||
|
* Deno.utimeSync("myfile.txt", 1556495550, new Date());
|
||||||
|
* ```
|
||||||
*
|
*
|
||||||
* Requires `allow-write` permission. */
|
* Requires `allow-write` permission. */
|
||||||
export function utimeSync(
|
export function utimeSync(
|
||||||
|
@ -900,7 +940,9 @@ declare namespace Deno {
|
||||||
* system object referenced by `path`. Given times are either in seconds
|
* system object referenced by `path`. Given times are either in seconds
|
||||||
* (UNIX epoch time) or as `Date` objects.
|
* (UNIX epoch time) or as `Date` objects.
|
||||||
*
|
*
|
||||||
* await Deno.utime("myfile.txt", 1556495550, new Date());
|
* ```ts
|
||||||
|
* await Deno.utime("myfile.txt", 1556495550, new Date());
|
||||||
|
* ```
|
||||||
*
|
*
|
||||||
* Requires `allow-write` permission. */
|
* Requires `allow-write` permission. */
|
||||||
export function utime(
|
export function utime(
|
||||||
|
@ -927,9 +969,11 @@ declare namespace Deno {
|
||||||
*
|
*
|
||||||
* Matches behavior of POSIX shutdown(3).
|
* Matches behavior of POSIX shutdown(3).
|
||||||
*
|
*
|
||||||
* const listener = Deno.listen({ port: 80 });
|
* ```ts
|
||||||
* const conn = await listener.accept();
|
* const listener = Deno.listen({ port: 80 });
|
||||||
* Deno.shutdown(conn.rid, Deno.ShutdownMode.Write);
|
* const conn = await listener.accept();
|
||||||
|
* Deno.shutdown(conn.rid, Deno.ShutdownMode.Write);
|
||||||
|
* ```
|
||||||
*/
|
*/
|
||||||
export function shutdown(rid: number, how: ShutdownMode): Promise<void>;
|
export function shutdown(rid: number, how: ShutdownMode): Promise<void>;
|
||||||
|
|
||||||
|
@ -964,7 +1008,9 @@ declare namespace Deno {
|
||||||
*
|
*
|
||||||
* Listen announces on the local transport address.
|
* Listen announces on the local transport address.
|
||||||
*
|
*
|
||||||
* const listener = Deno.listen({ path: "/foo/bar.sock", transport: "unix" })
|
* ```ts
|
||||||
|
* const listener = Deno.listen({ path: "/foo/bar.sock", transport: "unix" })
|
||||||
|
* ```
|
||||||
*
|
*
|
||||||
* Requires `allow-read` and `allow-write` permission. */
|
* Requires `allow-read` and `allow-write` permission. */
|
||||||
export function listen(
|
export function listen(
|
||||||
|
@ -975,15 +1021,17 @@ declare namespace Deno {
|
||||||
*
|
*
|
||||||
* Listen announces on the local transport address.
|
* Listen announces on the local transport address.
|
||||||
*
|
*
|
||||||
* const listener1 = Deno.listenDatagram({
|
* ```ts
|
||||||
* port: 80,
|
* const listener1 = Deno.listenDatagram({
|
||||||
* transport: "udp"
|
* port: 80,
|
||||||
* });
|
* transport: "udp"
|
||||||
* const listener2 = Deno.listenDatagram({
|
* });
|
||||||
* hostname: "golang.org",
|
* const listener2 = Deno.listenDatagram({
|
||||||
* port: 80,
|
* hostname: "golang.org",
|
||||||
* transport: "udp"
|
* port: 80,
|
||||||
* });
|
* transport: "udp"
|
||||||
|
* });
|
||||||
|
* ```
|
||||||
*
|
*
|
||||||
* Requires `allow-net` permission. */
|
* Requires `allow-net` permission. */
|
||||||
export function listenDatagram(
|
export function listenDatagram(
|
||||||
|
@ -994,10 +1042,12 @@ declare namespace Deno {
|
||||||
*
|
*
|
||||||
* Listen announces on the local transport address.
|
* Listen announces on the local transport address.
|
||||||
*
|
*
|
||||||
* const listener = Deno.listenDatagram({
|
* ```ts
|
||||||
* address: "/foo/bar.sock",
|
* const listener = Deno.listenDatagram({
|
||||||
* transport: "unixpacket"
|
* address: "/foo/bar.sock",
|
||||||
* });
|
* transport: "unixpacket"
|
||||||
|
* });
|
||||||
|
* ```
|
||||||
*
|
*
|
||||||
* Requires `allow-read` and `allow-write` permission. */
|
* Requires `allow-read` and `allow-write` permission. */
|
||||||
export function listenDatagram(
|
export function listenDatagram(
|
||||||
|
@ -1013,11 +1063,13 @@ declare namespace Deno {
|
||||||
* Connects to the hostname (default is "127.0.0.1") and port on the named
|
* Connects to the hostname (default is "127.0.0.1") and port on the named
|
||||||
* transport (default is "tcp"), and resolves to the connection (`Conn`).
|
* transport (default is "tcp"), and resolves to the connection (`Conn`).
|
||||||
*
|
*
|
||||||
* const conn1 = await Deno.connect({ port: 80 });
|
* ```ts
|
||||||
* const conn2 = await Deno.connect({ hostname: "192.0.2.1", port: 80 });
|
* const conn1 = await Deno.connect({ port: 80 });
|
||||||
* const conn3 = await Deno.connect({ hostname: "[2001:db8::1]", port: 80 });
|
* const conn2 = await Deno.connect({ hostname: "192.0.2.1", port: 80 });
|
||||||
* const conn4 = await Deno.connect({ hostname: "golang.org", port: 80, transport: "tcp" });
|
* const conn3 = await Deno.connect({ hostname: "[2001:db8::1]", port: 80 });
|
||||||
* const conn5 = await Deno.connect({ path: "/foo/bar.sock", transport: "unix" });
|
* const conn4 = await Deno.connect({ hostname: "golang.org", port: 80, transport: "tcp" });
|
||||||
|
* const conn5 = await Deno.connect({ path: "/foo/bar.sock", transport: "unix" });
|
||||||
|
* ```
|
||||||
*
|
*
|
||||||
* Requires `allow-net` permission for "tcp" and `allow-read` for unix. */
|
* Requires `allow-net` permission for "tcp" and `allow-read` for unix. */
|
||||||
export function connect(
|
export function connect(
|
||||||
|
@ -1041,8 +1093,10 @@ declare namespace Deno {
|
||||||
* Using this function requires that the other end of the connection is
|
* Using this function requires that the other end of the connection is
|
||||||
* prepared for TLS handshake.
|
* prepared for TLS handshake.
|
||||||
*
|
*
|
||||||
* const conn = await Deno.connect({ port: 80, hostname: "127.0.0.1" });
|
* ```ts
|
||||||
* const tlsConn = await Deno.startTls(conn, { certFile: "./certs/my_custom_root_CA.pem", hostname: "127.0.0.1", port: 80 });
|
* const conn = await Deno.connect({ port: 80, hostname: "127.0.0.1" });
|
||||||
|
* const tlsConn = await Deno.startTls(conn, { certFile: "./certs/my_custom_root_CA.pem", hostname: "127.0.0.1", port: 80 });
|
||||||
|
* ```
|
||||||
*
|
*
|
||||||
* Requires `allow-net` permission.
|
* Requires `allow-net` permission.
|
||||||
*/
|
*/
|
||||||
|
@ -1138,10 +1192,12 @@ declare namespace Deno {
|
||||||
export class Permissions {
|
export class Permissions {
|
||||||
/** Resolves to the current status of a permission.
|
/** Resolves to the current status of a permission.
|
||||||
*
|
*
|
||||||
* const status = await Deno.permissions.query({ name: "read", path: "/etc" });
|
* ```ts
|
||||||
* if (status.state === "granted") {
|
* const status = await Deno.permissions.query({ name: "read", path: "/etc" });
|
||||||
* data = await Deno.readFile("/etc/passwd");
|
* if (status.state === "granted") {
|
||||||
* }
|
* data = await Deno.readFile("/etc/passwd");
|
||||||
|
* }
|
||||||
|
* ```
|
||||||
*/
|
*/
|
||||||
query(desc: PermissionDescriptor): Promise<PermissionStatus>;
|
query(desc: PermissionDescriptor): Promise<PermissionStatus>;
|
||||||
|
|
||||||
|
@ -1154,12 +1210,14 @@ declare namespace Deno {
|
||||||
|
|
||||||
/** Requests the permission, and resolves to the state of the permission.
|
/** Requests the permission, and resolves to the state of the permission.
|
||||||
*
|
*
|
||||||
* const status = await Deno.permissions.request({ name: "env" });
|
* ```ts
|
||||||
* if (status.state === "granted") {
|
* const status = await Deno.permissions.request({ name: "env" });
|
||||||
* console.log(Deno.homeDir());
|
* if (status.state === "granted") {
|
||||||
* } else {
|
* console.log(Deno.homeDir());
|
||||||
* console.log("'env' permission is denied.");
|
* } else {
|
||||||
* }
|
* console.log("'env' permission is denied.");
|
||||||
|
* }
|
||||||
|
* ```
|
||||||
*/
|
*/
|
||||||
request(desc: PermissionDescriptor): Promise<PermissionStatus>;
|
request(desc: PermissionDescriptor): Promise<PermissionStatus>;
|
||||||
}
|
}
|
||||||
|
@ -1177,7 +1235,9 @@ declare namespace Deno {
|
||||||
|
|
||||||
/** Get the `hostname` of the machine the Deno process is running on.
|
/** Get the `hostname` of the machine the Deno process is running on.
|
||||||
*
|
*
|
||||||
* console.log(Deno.hostname());
|
* ```ts
|
||||||
|
* console.log(Deno.hostname());
|
||||||
|
* ```
|
||||||
*
|
*
|
||||||
* Requires `allow-env` permission.
|
* Requires `allow-env` permission.
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue