summaryrefslogtreecommitdiff
path: root/cli/dts/lib.deno.ns.d.ts
diff options
context:
space:
mode:
authorKitson Kelly <me@kitsonkelly.com>2022-08-17 13:12:24 +1000
committerGitHub <noreply@github.com>2022-08-17 13:12:24 +1000
commita2ab5eee015b1dafc1a18cd2bc5f5c5756123d74 (patch)
tree1efd7d79208fee44cc05c71c18c7d9e6759ed8c3 /cli/dts/lib.deno.ns.d.ts
parent868c7e38bfc9a09b5cfeae30ea5a2345a6d700d7 (diff)
docs: add category tag for built-in APIs (#15480)
Diffstat (limited to 'cli/dts/lib.deno.ns.d.ts')
-rw-r--r--cli/dts/lib.deno.ns.d.ts525
1 files changed, 454 insertions, 71 deletions
diff --git a/cli/dts/lib.deno.ns.d.ts b/cli/dts/lib.deno.ns.d.ts
index e5499c93e..71c94f695 100644
--- a/cli/dts/lib.deno.ns.d.ts
+++ b/cli/dts/lib.deno.ns.d.ts
@@ -6,7 +6,10 @@
/** Deno provides extra properties on `import.meta`. These are included here
* to ensure that these are still available when using the Deno namespace in
- * conjunction with other type libs, like `dom`. */
+ * conjunction with other type libs, like `dom`.
+ *
+ * @category ES Modules
+ */
declare interface ImportMeta {
/** A string representation of the fully qualified module URL. */
url: string;
@@ -36,7 +39,10 @@ declare interface ImportMeta {
/** Deno supports user timing Level 3 (see: https://w3c.github.io/user-timing)
* which is not widely supported yet in other runtimes. These types are here
* so that these features are still available when using the Deno namespace
- * in conjunction with other type libs, like `dom`. */
+ * in conjunction with other type libs, like `dom`.
+ *
+ * @category Performance API
+ */
declare interface Performance {
/** Stores a timestamp with the associated name (a "mark"). */
mark(markName: string, options?: PerformanceMarkOptions): PerformanceMark;
@@ -49,6 +55,9 @@ declare interface Performance {
): PerformanceMeasure;
}
+/**
+ * @category Performance API
+ */
declare interface PerformanceMarkOptions {
/** Metadata to be included in the mark. */
// deno-lint-ignore no-explicit-any
@@ -58,6 +67,9 @@ declare interface PerformanceMarkOptions {
startTime?: number;
}
+/**
+ * @category Performance API
+ */
declare interface PerformanceMeasureOptions {
/** Metadata to be included in the measure. */
// deno-lint-ignore no-explicit-any
@@ -75,37 +87,65 @@ declare interface PerformanceMeasureOptions {
}
declare namespace Deno {
- /** A set of error constructors that are raised by Deno APIs. */
+ /** A set of error constructors that are raised by Deno APIs.
+ *
+ * @category Errors
+ */
export namespace errors {
+ /** @category Errors */
export class NotFound extends Error {}
+ /** @category Errors */
export class PermissionDenied extends Error {}
+ /** @category Errors */
export class ConnectionRefused extends Error {}
+ /** @category Errors */
export class ConnectionReset extends Error {}
+ /** @category Errors */
export class ConnectionAborted extends Error {}
+ /** @category Errors */
export class NotConnected extends Error {}
+ /** @category Errors */
export class AddrInUse extends Error {}
+ /** @category Errors */
export class AddrNotAvailable extends Error {}
+ /** @category Errors */
export class BrokenPipe extends Error {}
+ /** @category Errors */
export class AlreadyExists extends Error {}
+ /** @category Errors */
export class InvalidData extends Error {}
+ /** @category Errors */
export class TimedOut extends Error {}
+ /** @category Errors */
export class Interrupted extends Error {}
+ /** @category Errors */
export class WriteZero extends Error {}
+ /** @category Errors */
export class UnexpectedEof extends Error {}
+ /** @category Errors */
export class BadResource extends Error {}
+ /** @category Errors */
export class Http extends Error {}
+ /** @category Errors */
export class Busy extends Error {}
+ /** @category Errors */
export class NotSupported extends Error {}
}
- /** The current process id of the runtime. */
+ /** The current process id of the runtime.
+ *
+ * @category Runtime Environment
+ */
export const pid: number;
/**
* The pid of the current process's parent.
+ *
+ * @category Runtime Environment
*/
export const ppid: number;
+ /** @category Runtime Environment */
export interface MemoryUsage {
rss: number;
heapTotal: number;
@@ -116,16 +156,23 @@ declare namespace Deno {
/**
* Returns an object describing the memory usage of the Deno process measured
* in bytes.
+ *
+ * @category Runtime Environment
*/
export function memoryUsage(): MemoryUsage;
/** Reflects the `NO_COLOR` environment variable at program start.
*
- * See: https://no-color.org/ */
+ * See: https://no-color.org/
+ *
+ * @category Runtime Environment
+ */
export const noColor: boolean;
+ /** @category Permissions */
export type PermissionOptions = "inherit" | "none" | PermissionOptionsObject;
+ /** @category Permissions */
export interface PermissionOptionsObject {
/** Specifies if the `env` permission should be requested or revoked.
* If set to `"inherit"`, the current `env` permission will be inherited.
@@ -259,6 +306,7 @@ declare namespace Deno {
write?: "inherit" | boolean | Array<string | URL>;
}
+ /** @category Testing */
export interface TestContext {
/**
* The current test name.
@@ -291,6 +339,7 @@ declare namespace Deno {
): Promise<boolean>;
}
+ /** @category Testing */
export interface TestStepDefinition {
fn: (t: TestContext) => void | Promise<void>;
/**
@@ -311,6 +360,7 @@ declare namespace Deno {
sanitizeExit?: boolean;
}
+ /** @category Testing */
export interface TestDefinition {
fn: (t: TestContext) => void | Promise<void>;
/**
@@ -371,6 +421,8 @@ declare namespace Deno {
* }
* });
* ```
+ *
+ * @category Testing
*/
export function test(t: TestDefinition): void;
@@ -391,6 +443,8 @@ declare namespace Deno {
* assertEquals(decoder.decode(data), "Hello world");
* });
* ```
+ *
+ * @category Testing
*/
export function test(
name: string,
@@ -414,6 +468,8 @@ declare namespace Deno {
* assertEquals(decoder.decode(data), "Hello world");
* });
* ```
+ *
+ * @category Testing
*/
export function test(fn: (t: TestContext) => void | Promise<void>): void;
@@ -434,6 +490,8 @@ declare namespace Deno {
* assertEquals(decoder.decode(data), "Hello world");
* });
* ```
+ *
+ * @category Testing
*/
export function test(
name: string,
@@ -458,6 +516,8 @@ declare namespace Deno {
* assertEquals(decoder.decode(data), "Hello world");
* });
* ```
+ *
+ * @category Testing
*/
export function test(
options: Omit<TestDefinition, "fn">,
@@ -481,6 +541,8 @@ declare namespace Deno {
* assertEquals(decoder.decode(data), "Hello world");
* });
* ```
+ *
+ * @category Testing
*/
export function test(
options: Omit<TestDefinition, "fn" | "name">,
@@ -495,9 +557,12 @@ declare namespace Deno {
* ```ts
* Deno.exit(5);
* ```
+ *
+ * @category Runtime Environment
*/
export function exit(code?: number): never;
+ /** @category Runtime Environment */
export const env: {
/** Retrieve the value of an environment variable. Returns `undefined` if that
* key doesn't exist.
@@ -551,6 +616,8 @@ declare namespace Deno {
* ```
*
* Requires `allow-read` permission.
+ *
+ * @category Runtime Environment
*/
export function execPath(): string;
@@ -568,6 +635,8 @@ declare namespace Deno {
* rights
*
* Requires --allow-read.
+ *
+ * @category Runtime Environment
*/
export function chdir(directory: string | URL): void;
@@ -584,6 +653,8 @@ declare namespace Deno {
* Throws `Deno.errors.NotFound` if directory not available.
*
* Requires --allow-read
+ *
+ * @category Runtime Environment
*/
export function cwd(): string;
@@ -594,7 +665,10 @@ declare namespace Deno {
* Deno.linkSync("old/name", "new/name");
* ```
*
- * Requires `allow-read` and `allow-write` permissions. */
+ * Requires `allow-read` and `allow-write` permissions.
+ *
+ * @category File System
+ */
export function linkSync(oldpath: string, newpath: string): void;
/**
@@ -604,15 +678,20 @@ declare namespace Deno {
* await Deno.link("old/name", "new/name");
* ```
*
- * Requires `allow-read` and `allow-write` permissions. */
+ * Requires `allow-read` and `allow-write` permissions.
+ *
+ * @category File System
+ */
export function link(oldpath: string, newpath: string): Promise<void>;
+ /** @category I/O */
export enum SeekMode {
Start = 0,
Current = 1,
End = 2,
}
+ /** @category I/O */
export interface Reader {
/** Reads up to `p.byteLength` bytes into `p`. It resolves to the number of
* bytes read (`0` < `n` <= `p.byteLength`) and rejects if any error
@@ -639,6 +718,7 @@ declare namespace Deno {
read(p: Uint8Array): Promise<number | null>;
}
+ /** @category I/O */
export interface ReaderSync {
/** Reads up to `p.byteLength` bytes into `p`. It resolves to the number
* of bytes read (`0` < `n` <= `p.byteLength`) and rejects if any error
@@ -664,6 +744,7 @@ declare namespace Deno {
readSync(p: Uint8Array): number | null;
}
+ /** @category I/O */
export interface Writer {
/** Writes `p.byteLength` bytes from `p` to the underlying data stream. It
* resolves to the number of bytes written from `p` (`0` <= `n` <=
@@ -677,6 +758,7 @@ declare namespace Deno {
write(p: Uint8Array): Promise<number>;
}
+ /** @category I/O */
export interface WriterSync {
/** Writes `p.byteLength` bytes from `p` to the underlying data
* stream. It returns the number of bytes written from `p` (`0` <= `n`
@@ -690,10 +772,12 @@ declare namespace Deno {
writeSync(p: Uint8Array): number;
}
+ /** @category I/O */
export interface Closer {
close(): void;
}
+ /** @category I/O */
export interface Seeker {
/** Seek sets the offset for the next `read()` or `write()` to offset,
* interpreted according to `whence`: `Start` means relative to the
@@ -709,6 +793,7 @@ declare namespace Deno {
seek(offset: number, whence: SeekMode): Promise<number>;
}
+ /** @category I/O */
export interface SeekerSync {
/** Seek sets the offset for the next `readSync()` or `writeSync()` to
* offset, interpreted according to `whence`: `Start` means relative
@@ -737,6 +822,8 @@ declare namespace Deno {
* @deprecated Use `copy` from https://deno.land/std/streams/conversion.ts
* instead. `Deno.copy` will be removed in Deno 2.0.
*
+ * @category I/O
+ *
* @param src The source to copy from
* @param dst The destination to copy to
* @param options Can be used to tune size of the buffer. Default size is 32kB
@@ -782,6 +869,8 @@ declare namespace Deno {
* @deprecated Use `iterateReader` from
* https://deno.land/std/streams/conversion.ts instead. `Deno.iter` will be
* removed in Deno 2.0.
+ *
+ * @category I/O
*/
export function iter(
r: Reader,
@@ -823,6 +912,8 @@ declare namespace Deno {
* @deprecated Use `iterateReaderSync` from
* https://deno.land/std/streams/conversion.ts instead. `Deno.iterSync` will
* be removed in Deno 2.0.
+ *
+ * @category I/O
*/
export function iterSync(
r: ReaderSync,
@@ -843,6 +934,8 @@ declare namespace Deno {
* ```
*
* Requires `allow-read` and/or `allow-write` permissions depending on options.
+ *
+ * @category File System
*/
export function openSync(path: string | URL, options?: OpenOptions): FsFile;
@@ -858,6 +951,8 @@ declare namespace Deno {
* ```
*
* Requires `allow-read` and/or `allow-write` permissions depending on options.
+ *
+ * @category File System
*/
export function open(
path: string | URL,
@@ -872,6 +967,8 @@ declare namespace Deno {
* ```
*
* Requires `allow-read` and `allow-write` permissions.
+ *
+ * @category File System
*/
export function createSync(path: string | URL): FsFile;
@@ -883,6 +980,8 @@ declare namespace Deno {
* ```
*
* Requires `allow-read` and `allow-write` permissions.
+ *
+ * @category File System
*/
export function create(path: string | URL): Promise<FsFile>;
@@ -908,6 +1007,8 @@ declare namespace Deno {
* const text = new TextDecoder().decode(buf); // "hello world"
* Deno.close(file.rid);
* ```
+ *
+ * @category I/O
*/
export function readSync(rid: number, buffer: Uint8Array): number | null;
@@ -933,6 +1034,8 @@ declare namespace Deno {
* const text = new TextDecoder().decode(buf); // "hello world"
* Deno.close(file.rid);
* ```
+ *
+ * @category I/O
*/
export function read(rid: number, buffer: Uint8Array): Promise<number | null>;
@@ -953,6 +1056,8 @@ declare namespace Deno {
* const bytesWritten = Deno.writeSync(file.rid, data); // 11
* Deno.close(file.rid);
* ```
+ *
+ * @category I/O
*/
export function writeSync(rid: number, data: Uint8Array): number;
@@ -972,6 +1077,8 @@ declare namespace Deno {
* const bytesWritten = await Deno.write(file.rid, data); // 11
* Deno.close(file.rid);
* ```
+ *
+ * @category I/O
*/
export function write(rid: number, data: Uint8Array): Promise<number>;
@@ -1005,6 +1112,8 @@ declare namespace Deno {
* // Seek backwards 2 bytes from the end of the file
* console.log(Deno.seekSync(file.rid, -2, Deno.SeekMode.End)); // "9" (e.g. 11-2)
* ```
+ *
+ * @category I/O
*/
export function seekSync(
rid: number,
@@ -1042,6 +1151,8 @@ declare namespace Deno {
* // Seek backwards 2 bytes from the end of the file
* console.log(await Deno.seek(file.rid, -2, Deno.SeekMode.End)); // "9" (e.g. 11-2)
* ```
+ *
+ * @category I/O
*/
export function seek(
rid: number,
@@ -1050,37 +1161,49 @@ declare namespace Deno {
): Promise<number>;
/**
- * Synchronously flushes any pending data and metadata operations of the given file stream to disk.
- * ```ts
+ * Synchronously flushes any pending data and metadata operations of the given
+ * file stream to disk.
+ *
+ * ```ts
* const file = Deno.openSync("my_file.txt", { read: true, write: true, create: true });
* Deno.writeSync(file.rid, new TextEncoder().encode("Hello World"));
* Deno.ftruncateSync(file.rid, 1);
* Deno.fsyncSync(file.rid);
* console.log(new TextDecoder().decode(Deno.readFileSync("my_file.txt"))); // H
* ```
+ *
+ * @category I/O
*/
export function fsyncSync(rid: number): void;
/**
- * Flushes any pending data and metadata operations of the given file stream to disk.
- * ```ts
+ * Flushes any pending data and metadata operations of the given file stream
+ * to disk.
+ *
+ * ```ts
* const file = await Deno.open("my_file.txt", { read: true, write: true, create: true });
* await Deno.write(file.rid, new TextEncoder().encode("Hello World"));
* await Deno.ftruncate(file.rid, 1);
* await Deno.fsync(file.rid);
* console.log(new TextDecoder().decode(await Deno.readFile("my_file.txt"))); // H
* ```
+ *
+ * @category I/O
*/
export function fsync(rid: number): Promise<void>;
- /*
- * Synchronously flushes any pending data operations of the given file stream to disk.
+ /**
+ * Synchronously flushes any pending data operations of the given file stream
+ * to disk.
+ *
* ```ts
* const file = Deno.openSync("my_file.txt", { read: true, write: true, create: true });
* Deno.writeSync(file.rid, new TextEncoder().encode("Hello World"));
* Deno.fdatasyncSync(file.rid);
* console.log(new TextDecoder().decode(Deno.readFileSync("my_file.txt"))); // Hello World
* ```
+ *
+ * @category I/O
*/
export function fdatasyncSync(rid: number): void;
@@ -1092,6 +1215,8 @@ declare namespace Deno {
* await Deno.fdatasync(file.rid);
* console.log(new TextDecoder().decode(await Deno.readFile("my_file.txt"))); // Hello World
* ```
+ *
+ * @category I/O
*/
export function fdatasync(rid: number): Promise<void>;
@@ -1103,11 +1228,16 @@ declare namespace Deno {
* const file = await Deno.open("my_file.txt");
* // do work with "file" object
* Deno.close(file.rid);
- * ````
+ * ```
+ *
+ * @category I/O
*/
export function close(rid: number): void;
- /** The Deno abstraction for reading and writing files. */
+ /** The Deno abstraction for reading and writing files.
+ *
+ * @category File System
+ */
export class FsFile
implements
Reader,
@@ -1136,9 +1266,10 @@ declare namespace Deno {
}
/**
- * @deprecated Use `Deno.FsFile` instead. `Deno.File` will be removed in Deno 2.0.
- *
* The Deno abstraction for reading and writing files.
+ *
+ * @deprecated Use `Deno.FsFile` instead. `Deno.File` will be removed in Deno 2.0.
+ * @category File System
*/
export class File
implements
@@ -1167,12 +1298,18 @@ declare namespace Deno {
readonly writable: WritableStream<Uint8Array>;
}
- /** A handle for `stdin`. */
+ /** A handle for `stdin`.
+ *
+ * @category I/O
+ */
export const stdin: Reader & ReaderSync & Closer & {
readonly rid: number;
readonly readable: ReadableStream<Uint8Array>;
};
- /** A handle for `stdout`. */
+ /** A handle for `stdout`.
+ *
+ * @category I/O
+ */
export const stdout: Writer & WriterSync & Closer & {
readonly rid: number;
readonly writable: WritableStream<Uint8Array>;
@@ -1183,6 +1320,7 @@ declare namespace Deno {
readonly writable: WritableStream<Uint8Array>;
};
+ /** @category File System */
export interface OpenOptions {
/** Sets the option for read access. This option, when `true`, means that the
* file should be read-able if opened. */
@@ -1217,6 +1355,7 @@ declare namespace Deno {
mode?: number;
}
+ /** @category File System */
export interface ReadFileOptions {
/**
* An abort signal to allow cancellation of the file read operation.
@@ -1238,12 +1377,12 @@ declare namespace Deno {
* Deno.close(nonTTYRid);
* Deno.close(ttyRid);
* ```
+ *
+ * @category I/O
*/
export function isatty(rid: number): boolean;
/**
- * @deprecated Use Buffer from https://deno.land/std/io/buffer.ts instead. Deno.Buffer will be removed in Deno 2.0.
- *
* A variable-sized buffer of bytes with `read()` and `write()` methods.
*
* Deno.Buffer is almost always used with some I/O like files and sockets. It
@@ -1257,7 +1396,11 @@ declare namespace Deno {
* ArrayBuffer is a fixed memory allocation. Deno.Buffer is implemented on top
* of ArrayBuffer.
*
- * Based on [Go Buffer](https://golang.org/pkg/bytes/#Buffer). */
+ * Based on [Go Buffer](https://golang.org/pkg/bytes/#Buffer).
+ *
+ * @deprecated Use Buffer from https://deno.land/std/io/buffer.ts instead. Deno.Buffer will be removed in Deno 2.0.
+ * @category I/O
+ */
export class Buffer implements Reader, ReaderSync, Writer, WriterSync {
constructor(ab?: ArrayBuffer);
/** Returns a slice holding the unread portion of the buffer.
@@ -1346,6 +1489,8 @@ declare namespace Deno {
*
* @deprecated Use `readAll` from https://deno.land/std/streams/conversion.ts
* instead. `Deno.readAll` will be removed in Deno 2.0.
+ *
+ * @category I/O
*/
export function readAll(r: Reader): Promise<Uint8Array>;
@@ -1372,6 +1517,8 @@ declare namespace Deno {
* @deprecated Use `readAllSync` from
* https://deno.land/std/streams/conversion.ts instead. `Deno.readAllSync`
* will be removed in Deno 2.0.
+ *
+ * @category I/O
*/
export function readAllSync(r: ReaderSync): Uint8Array;
@@ -1402,6 +1549,8 @@ declare namespace Deno {
*
* @deprecated Use `writeAll` from https://deno.land/std/streams/conversion.ts
* instead. `Deno.writeAll` will be removed in Deno 2.0.
+ *
+ * @category I/O
*/
export function writeAll(w: Writer, arr: Uint8Array): Promise<void>;
@@ -1434,9 +1583,12 @@ declare namespace Deno {
* @deprecated Use `writeAllSync` from
* https://deno.land/std/streams/conversion.ts instead. `Deno.writeAllSync`
* will be removed in Deno 2.0.
+ *
+ * @category I/O
*/
export function writeAllSync(w: WriterSync, arr: Uint8Array): void;
+ /** @category File System */
export interface MkdirOptions {
/** Defaults to `false`. If set to `true`, means that any intermediate
* directories will also be created (as with the shell command `mkdir -p`).
@@ -1461,7 +1613,10 @@ declare namespace Deno {
*
* Defaults to throwing error if the directory already exists.
*
- * Requires `allow-write` permission. */
+ * Requires `allow-write` permission.
+ *
+ * @category File System
+ */
export function mkdirSync(path: string | URL, options?: MkdirOptions): void;
/** Creates a new directory with the specified path.
@@ -1474,12 +1629,16 @@ declare namespace Deno {
*
* Defaults to throwing error if the directory already exists.
*
- * Requires `allow-write` permission. */
+ * Requires `allow-write` permission.
+ *
+ * @category File System
+ */
export function mkdir(
path: string | URL,
options?: MkdirOptions,
): Promise<void>;
+ /** @category File System */
export interface MakeTempOptions {
/** Directory where the temporary directory should be created (defaults to
* the env variable TMPDIR, or the system's default, usually /tmp).
@@ -1512,7 +1671,10 @@ declare namespace Deno {
* const tempDirName1 = Deno.makeTempDirSync({ prefix: 'my_temp' }); // e.g. /tmp/my_temp339c944d
* ```
*
- * Requires `allow-write` permission. */
+ * Requires `allow-write` permission.
+ *
+ * @category File System
+ */
// TODO(ry) Doesn't check permissions.
export function makeTempDirSync(options?: MakeTempOptions): string;
@@ -1532,7 +1694,10 @@ declare namespace Deno {
* const tempDirName1 = await Deno.makeTempDir({ prefix: 'my_temp' }); // e.g. /tmp/my_temp339c944d
* ```
*
- * Requires `allow-write` permission. */
+ * Requires `allow-write` permission.
+ *
+ * @category File System
+ */
// TODO(ry) Doesn't check permissions.
export function makeTempDir(options?: MakeTempOptions): Promise<string>;
@@ -1552,7 +1717,10 @@ declare namespace Deno {
* const tempFileName1 = Deno.makeTempFileSync({ prefix: 'my_temp' }); // e.g. /tmp/my_temp754d3098
* ```
*
- * Requires `allow-write` permission. */
+ * Requires `allow-write` permission.
+ *
+ * @category File System
+ */
export function makeTempFileSync(options?: MakeTempOptions): string;
/** Creates a new temporary file in the default directory for temporary
@@ -1571,7 +1739,10 @@ declare namespace Deno {
* const tmpFileName1 = await Deno.makeTempFile({ prefix: 'my_temp' }); // e.g. /tmp/my_temp754d3098
* ```
*
- * Requires `allow-write` permission. */
+ * Requires `allow-write` permission.
+ *
+ * @category File System
+ */
export function makeTempFile(options?: MakeTempOptions): Promise<string>;
/** Synchronously changes the permission of a specific file/directory of
@@ -1585,7 +1756,10 @@ declare namespace Deno {
*
* NOTE: This API currently throws on Windows
*
- * Requires `allow-write` permission. */
+ * Requires `allow-write` permission.
+ *
+ * @category File System
+ */
export function chmodSync(path: string | URL, mode: number): void;
/** Changes the permission of a specific file/directory of specified path.
@@ -1615,7 +1789,10 @@ declare namespace Deno {
*
* NOTE: This API currently throws on Windows
*
- * Requires `allow-write` permission. */
+ * Requires `allow-write` permission.
+ *
+ * @category File System
+ */
export function chmod(path: string | URL, mode: number): Promise<void>;
/** Synchronously change owner of a regular file or directory. This functionality
@@ -1629,6 +1806,8 @@ declare namespace Deno {
*
* Throws Error (not implemented) if executed on Windows
*
+ * @category File System
+ *
* @param path path to the file
* @param uid user id (UID) of the new owner, or `null` for no change
* @param gid group id (GID) of the new owner, or `null` for no change
@@ -1650,6 +1829,8 @@ declare namespace Deno {
*
* Throws Error (not implemented) if executed on Windows
*
+ * @category File System
+ *
* @param path path to the file
* @param uid user id (UID) of the new owner, or `null` for no change
* @param gid group id (GID) of the new owner, or `null` for no change
@@ -1660,6 +1841,7 @@ declare namespace Deno {
gid: number | null,
): Promise<void>;
+ /** @category File System */
export interface RemoveOptions {
/** Defaults to `false`. If set to `true`, path will be removed even if
* it's a non-empty directory. */
@@ -1676,7 +1858,10 @@ declare namespace Deno {
* Throws error if permission denied, path not found, or path is a non-empty
* directory and the `recursive` option isn't set to `true`.
*
- * Requires `allow-write` permission. */
+ * Requires `allow-write` permission.
+ *
+ * @category File System
+ */
export function removeSync(path: string | URL, options?: RemoveOptions): void;
/** Removes the named file or directory.
@@ -1689,7 +1874,10 @@ declare namespace Deno {
* Throws error if permission denied, path not found, or path is a non-empty
* directory and the `recursive` option isn't set to `true`.
*
- * Requires `allow-write` permission. */
+ * Requires `allow-write` permission.
+ *
+ * @category File System
+ */
export function remove(
path: string | URL,
options?: RemoveOptions,
@@ -1709,7 +1897,10 @@ declare namespace Deno {
* It varies between platforms when the operation throws errors, and if so what
* they are. It's always an error to rename anything to a non-empty directory.
*
- * Requires `allow-read` and `allow-write` permissions. */
+ * Requires `allow-read` and `allow-write` permissions.
+ *
+ * @category File System
+ */
export function renameSync(
oldpath: string | URL,
newpath: string | URL,
@@ -1729,7 +1920,10 @@ declare namespace Deno {
* It varies between platforms when the operation throws errors, and if so what
* they are. It's always an error to rename anything to a non-empty directory.
*
- * Requires `allow-read` and `allow-write` permission. */
+ * Requires `allow-read` and `allow-write` permission.
+ *
+ * @category File System
+ */
export function rename(
oldpath: string | URL,
newpath: string | URL,
@@ -1743,7 +1937,10 @@ declare namespace Deno {
* console.log(data);
* ```
*
- * Requires `allow-read` permission. */
+ * Requires `allow-read` permission.
+ *
+ * @category File System
+ */
export function readTextFileSync(path: string | URL): string;
/** Asynchronously reads and returns the entire contents of a file as utf8
@@ -1754,7 +1951,10 @@ declare namespace Deno {
* console.log(data);
* ```
*
- * Requires `allow-read` permission. */
+ * Requires `allow-read` permission.
+ *
+ * @category File System
+ */
export function readTextFile(
path: string | URL,
options?: ReadFileOptions,
@@ -1770,7 +1970,10 @@ declare namespace Deno {
* console.log(decoder.decode(data));
* ```
*
- * Requires `allow-read` permission. */
+ * Requires `allow-read` permission.
+ *
+ * @category File System
+ */
export function readFileSync(path: string | URL): Uint8Array;
/** Reads and resolves to the entire contents of a file as an array of bytes.
@@ -1783,14 +1986,20 @@ declare namespace Deno {
* console.log(decoder.decode(data));
* ```
*
- * Requires `allow-read` permission. */
+ * Requires `allow-read` permission.
+ *
+ * @category File System
+ */
export function readFile(
path: string | URL,
options?: ReadFileOptions,
): Promise<Uint8Array>;
/** A FileInfo describes a file and is returned by `stat`, `lstat`,
- * `statSync`, `lstatSync`. */
+ * `statSync`, `lstatSync`.
+ *
+ * @category File System
+ */
export interface FileInfo {
/** True if this is info for a regular file. Mutually exclusive to
* `FileInfo.isDirectory` and `FileInfo.isSymlink`. */
@@ -1867,7 +2076,10 @@ declare namespace Deno {
*
* Requires `allow-read` permission for the target path.
* Also requires `allow-read` permission for the CWD if the target path is
- * relative. */
+ * relative.
+ *
+ * @category File System
+ */
export function realPathSync(path: string | URL): string;
/** Resolves to the absolute normalized path, with symbolic links resolved.
@@ -1883,7 +2095,10 @@ declare namespace Deno {
*
* Requires `allow-read` permission for the target path.
* Also requires `allow-read` permission for the CWD if the target path is
- * relative. */
+ * relative.
+ *
+ * @category File System
+ */
export function realPath(path: string | URL): Promise<string>;
export interface DirEntry {
@@ -1904,7 +2119,10 @@ declare namespace Deno {
*
* Throws error if `path` is not a directory.
*
- * Requires `allow-read` permission. */
+ * Requires `allow-read` permission.
+ *
+ * @category File System
+ */
export function readDirSync(path: string | URL): Iterable<DirEntry>;
/** Reads the directory given by `path` and returns an async iterable of
@@ -1918,7 +2136,10 @@ declare namespace Deno {
*
* Throws error if `path` is not a directory.
*
- * Requires `allow-read` permission. */
+ * Requires `allow-read` permission.
+ *
+ * @category File System
+ */
export function readDir(path: string | URL): AsyncIterable<DirEntry>;
/** Synchronously copies the contents and permissions of one file to another
@@ -1930,7 +2151,10 @@ declare namespace Deno {
* ```
*
* Requires `allow-read` permission on fromPath.
- * Requires `allow-write` permission on toPath. */
+ * Requires `allow-write` permission on toPath.
+ *
+ * @category File System
+ */
export function copyFileSync(
fromPath: string | URL,
toPath: string | URL,
@@ -1945,7 +2169,10 @@ declare namespace Deno {
* ```
*
* Requires `allow-read` permission on fromPath.
- * Requires `allow-write` permission on toPath. */
+ * Requires `allow-write` permission on toPath.
+ *
+ * @category File System
+ */
export function copyFile(
fromPath: string | URL,
toPath: string | URL,
@@ -1960,7 +2187,10 @@ declare namespace Deno {
*
* Throws TypeError if called with a hard link
*
- * Requires `allow-read` permission. */
+ * Requires `allow-read` permission.
+ *
+ * @category File System
+ */
export function readLinkSync(path: string | URL): string;
/** Resolves to the full path destination of the named symbolic link.
@@ -1972,7 +2202,10 @@ declare namespace Deno {
*
* Throws TypeError if called with a hard link
*
- * Requires `allow-read` permission. */
+ * Requires `allow-read` permission.
+ *
+ * @category File System
+ */
export function readLink(path: string | URL): Promise<string>;
/** Resolves to a `Deno.FileInfo` for the specified `path`. If `path` is a
@@ -1985,7 +2218,10 @@ declare namespace Deno {
* assert(fileInfo.isFile);
* ```
*
- * Requires `allow-read` permission. */
+ * Requires `allow-read` permission.
+ *
+ * @category File System
+ */
export function lstat(path: string | URL): Promise<FileInfo>;
/** Synchronously returns a `Deno.FileInfo` for the specified `path`. If
@@ -1998,7 +2234,10 @@ declare namespace Deno {
* assert(fileInfo.isFile);
* ```
*
- * Requires `allow-read` permission. */
+ * Requires `allow-read` permission.
+ *
+ * @category File System
+ */
export function lstatSync(path: string | URL): FileInfo;
/** Resolves to a `Deno.FileInfo` for the specified `path`. Will always
@@ -2010,7 +2249,10 @@ declare namespace Deno {
* assert(fileInfo.isFile);
* ```
*
- * Requires `allow-read` permission. */
+ * Requires `allow-read` permission.
+ *
+ * @category File System
+ */
export function stat(path: string | URL): Promise<FileInfo>;
/** Synchronously returns a `Deno.FileInfo` for the specified `path`. Will
@@ -2022,10 +2264,16 @@ declare namespace Deno {
* assert(fileInfo.isFile);
* ```
*
- * Requires `allow-read` permission. */
+ * Requires `allow-read` permission.
+ *
+ * @category File System
+ */
export function statSync(path: string | URL): FileInfo;
- /** Options for writing to a file. */
+ /** Options for writing to a file.
+ *
+ * @category File System
+ */
export interface WriteFileOptions {
/** Defaults to `false`. If set to `true`, will append to a file instead of
* overwriting previous contents. */
@@ -2057,6 +2305,8 @@ declare namespace Deno {
*
* Requires `allow-write` permission, and `allow-read` if `options.create` is
* `false`.
+ *
+ * @category File System
*/
export function writeFileSync(
path: string | URL,
@@ -2077,6 +2327,8 @@ declare namespace Deno {
* ```
*
* Requires `allow-write` permission, and `allow-read` if `options.create` is `false`.
+ *
+ * @category File System
*/
export function writeFile(
path: string | URL,
@@ -2092,6 +2344,8 @@ declare namespace Deno {
* ```
*
* Requires `allow-write` permission, and `allow-read` if `options.create` is `false`.
+ *
+ * @category File System
*/
export function writeTextFileSync(
path: string | URL,
@@ -2107,6 +2361,8 @@ declare namespace Deno {
* ```
*
* Requires `allow-write` permission, and `allow-read` if `options.create` is `false`.
+ *
+ * @category File System
*/
export function writeTextFile(
path: string | URL,
@@ -2130,7 +2386,10 @@ declare namespace Deno {
* console.log(new TextDecoder().decode(data));
* ```
*
- * Requires `allow-write` permission. */
+ * Requires `allow-write` permission.
+ *
+ * @category File System
+ */
export function truncateSync(name: string, len?: number): void;
/** Truncates or extends the specified file, to reach the specified `len`. If
@@ -2148,9 +2407,13 @@ declare namespace Deno {
* console.log(new TextDecoder().decode(data)); // "Hello W"
* ```
*
- * Requires `allow-write` permission. */
+ * Requires `allow-write` permission.
+ *
+ * @category File System
+ */
export function truncate(name: string, len?: number): Promise<void>;
+ /** @category Observability */
export interface OpMetrics {
opsDispatched: number;
opsDispatchedSync: number;
@@ -2165,6 +2428,7 @@ declare namespace Deno {
bytesReceived: number;
}
+ /** @category Observability */
export interface Metrics extends OpMetrics {
ops: Record<string, OpMetrics>;
}
@@ -2189,9 +2453,12 @@ declare namespace Deno {
* │ bytesSentData │ 0 │
* │ bytesReceived │ 375 │
* └─────────────────────────┴────────┘
+ *
+ * @category Observability
*/
export function metrics(): Metrics;
+ /** @category Observability */
interface ResourceMap {
// deno-lint-ignore no-explicit-any
[rid: number]: any;
@@ -2208,6 +2475,8 @@ declare namespace Deno {
* console.log(Deno.resources());
* // { 0: "stdin", 1: "stdout", 2: "stderr", 3: "fsFile" }
* ```
+ *
+ * @category Observability
*/
export function resources(): ResourceMap;
@@ -2221,9 +2490,12 @@ declare namespace Deno {
* An application that keeps an in-memory representation of the filesystem
* will need to care, and will need to refresh that representation directly
* from the filesystem.
+ *
+ * @category File System
*/
export type FsEventFlag = "rescan";
+ /** @category File System */
export interface FsEvent {
kind: "any" | "access" | "create" | "modify" | "remove" | "other";
paths: string[];
@@ -2235,6 +2507,8 @@ declare namespace Deno {
* the file system. You can iterate over this interface to get the file
* system events, and also you can stop watching the file system by calling
* `.close()` method.
+ *
+ * @category File System
*/
export interface FsWatcher extends AsyncIterable<FsEvent> {
/** The resource id of the `FsWatcher`. */
@@ -2281,12 +2555,15 @@ declare namespace Deno {
* console.log(">>>> event", event);
* }
* ```
+ *
+ * @category File System
*/
export function watchFs(
paths: string | string[],
options?: { recursive: boolean },
): FsWatcher;
+ /** @category Runtime Environment */
export class Process<T extends RunOptions = RunOptions> {
readonly rid: number;
readonly pid: number;
@@ -2351,6 +2628,7 @@ declare namespace Deno {
kill(signo: Signal): void;
}
+ /** @category Runtime Environment */
export type Signal =
| "SIGABRT"
| "SIGALRM"
@@ -2396,6 +2674,8 @@ declare namespace Deno {
* ```
*
* NOTE: On Windows only SIGINT (ctrl+c) and SIGBREAK (ctrl+break) are supported.
+ *
+ * @category Runtime Environment
*/
export function addSignalListener(signal: Signal, handler: () => void): void;
@@ -2411,6 +2691,8 @@ declare namespace Deno {
* ```
*
* NOTE: On Windows only SIGINT (ctrl+c) and SIGBREAK (ctrl+break) are supported.
+ *
+ * @category Runtime Environment
*/
export function removeSignalListener(
signal: Signal,
@@ -2429,6 +2711,7 @@ declare namespace Deno {
signal?: number;
};
+ /** @category Sub Process */
export interface RunOptions {
/** Arguments to pass. Note, the first element needs to be a path to the
* binary */
@@ -2484,9 +2767,13 @@ declare namespace Deno {
*
* Details of the spawned process are returned.
*
- * Requires `allow-run` permission. */
+ * Requires `allow-run` permission.
+ *
+ * @category Sub Process
+ */
export function run<T extends RunOptions = RunOptions>(opt: T): Process<T>;
+ /** @category Console and Debugging */
export interface InspectOptions {
/** Stylize output with ANSI colors. Defaults to false. */
colors?: boolean;
@@ -2544,10 +2831,15 @@ declare namespace Deno {
* ```ts
* Deno.inspect({a: {b: {c: {d: 'hello'}}}}, {depth: 2}); // { a: { b: [Object] } }
* ```
+ *
+ * @category Console and Debugging
*/
export function inspect(value: unknown, options?: InspectOptions): string;
- /** The name of a "powerful feature" which needs permission. */
+ /** The name of a "powerful feature" which needs permission.
+ *
+ * @category Permissions
+ */
export type PermissionName =
| "run"
| "read"
@@ -2557,24 +2849,31 @@ declare namespace Deno {
| "ffi"
| "hrtime";
- /** The current status of the permission. */
+ /** The current status of the permission.
+ *
+ * @category Permissions
+ */
export type PermissionState = "granted" | "denied" | "prompt";
+ /** @category Permissions */
export interface RunPermissionDescriptor {
name: "run";
command?: string | URL;
}
+ /** @category Permissions */
export interface ReadPermissionDescriptor {
name: "read";
path?: string | URL;
}
+ /** @category Permissions */
export interface WritePermissionDescriptor {
name: "write";
path?: string | URL;
}
+ /** @category Permissions */
export interface NetPermissionDescriptor {
name: "net";
/** Optional host string of the form `"<hostname>[:<port>]"`. Examples:
@@ -2585,22 +2884,28 @@ declare namespace Deno {
host?: string;
}
+ /** @category Permissions */
export interface EnvPermissionDescriptor {
name: "env";
variable?: string;
}
+ /** @category Permissions */
export interface FfiPermissionDescriptor {
name: "ffi";
path?: string | URL;
}
+ /** @category Permissions */
export interface HrtimePermissionDescriptor {
name: "hrtime";
}
/** Permission descriptors which define a permission and can be queried,
- * requested, or revoked. */
+ * requested, or revoked.
+ *
+ * @category Permissions
+ */
export type PermissionDescriptor =
| RunPermissionDescriptor
| ReadPermissionDescriptor
@@ -2610,10 +2915,12 @@ declare namespace Deno {
| FfiPermissionDescriptor
| HrtimePermissionDescriptor;
+ /** @category Permissions */
export interface PermissionStatusEventMap {
"change": Event;
}
+ /** @category Permissions */
export class PermissionStatus extends EventTarget {
// deno-lint-ignore no-explicit-any
onchange: ((this: PermissionStatus, ev: Event) => any) | null;
@@ -2646,6 +2953,7 @@ declare namespace Deno {
): void;
}
+ /** @category Permissions */
export class Permissions {
/** Resolves to the current status of a permission.
*
@@ -2681,10 +2989,16 @@ declare namespace Deno {
request(desc: PermissionDescriptor): Promise<PermissionStatus>;
}
- /** Deno's permission management API. */
+ /** Deno's permission management API.
+ *
+ * @category Permissions
+ */
export const permissions: Permissions;
- /** Build related information. */
+ /** Build related information.
+ *
+ * @category Runtime Environment
+ */
export const build: {
/** The LLVM target triple */
target: string;
@@ -2698,7 +3012,10 @@ declare namespace Deno {
env?: string;
};
- /** Version related information. */
+ /** Version related information.
+ *
+ * @category Runtime Environment
+ */
export const version: {
/** Deno's version. For example: `"1.0.0"` */
deno: string;
@@ -2716,6 +3033,8 @@ declare namespace Deno {
* Then `Deno.args` will contain:
*
* [ "/etc/passwd" ]
+ *
+ * @category Runtime Environment
*/
export const args: string[];
@@ -2726,12 +3045,18 @@ declare namespace Deno {
*
* @deprecated This symbol is deprecated since 1.9. Use
* `Symbol.for("Deno.customInspect")` instead.
+ *
+ * @category Console and Debugging
*/
export const customInspect: unique symbol;
- /** The URL of the entrypoint module entered from the command-line. */
+ /** The URL of the entrypoint module entered from the command-line.
+ *
+ * @category Runtime Environment
+ */
export const mainModule: string;
+ /** @category File System */
export type SymlinkOptions = {
type: "file" | "dir";
};
@@ -2746,7 +3071,10 @@ declare namespace Deno {
* Deno.symlinkSync("old/name", "new/name");
* ```
*
- * Requires full `allow-read` and `allow-write` permissions. */
+ * Requires full `allow-read` and `allow-write` permissions.
+ *
+ * @category File System
+ */
export function symlinkSync(
oldpath: string | URL,
newpath: string | URL,
@@ -2763,7 +3091,10 @@ declare namespace Deno {
* await Deno.symlink("old/name", "new/name");
* ```
*
- * Requires full `allow-read` and `allow-write` permissions. */
+ * Requires full `allow-read` and `allow-write` permissions.
+ *
+ * @category File System
+ */
export function symlink(
oldpath: string | URL,
newpath: string | URL,
@@ -2796,6 +3127,8 @@ declare namespace Deno {
* Deno.readSync(file.rid, data);
* console.log(new TextDecoder().decode(data)); // Hello W
* ```
+ *
+ * @category File System
*/
export function ftruncateSync(rid: number, len?: number): void;
@@ -2823,6 +3156,8 @@ declare namespace Deno {
* await Deno.read(file.rid, data);
* console.log(new TextDecoder().decode(data)); // Hello W
* ```
+ *
+ * @category File System
*/
export function ftruncate(rid: number, len?: number): Promise<void>;
@@ -2835,6 +3170,8 @@ declare namespace Deno {
* const fileInfo = Deno.fstatSync(file.rid);
* assert(fileInfo.isFile);
* ```
+ *
+ * @category File System
*/
export function fstatSync(rid: number): FileInfo;
@@ -2847,14 +3184,18 @@ declare namespace Deno {
* const fileInfo = await Deno.fstat(file.rid);
* assert(fileInfo.isFile);
* ```
+ *
+ * @category File System
*/
export function fstat(rid: number): Promise<FileInfo>;
+ /** @category HTTP Server */
export interface RequestEvent {
readonly request: Request;
respondWith(r: Response | Promise<Response>): Promise<void>;
}
+ /** @category HTTP Server */
export interface HttpConn extends AsyncIterable<RequestEvent> {
readonly rid: number;
@@ -2890,14 +3231,18 @@ declare namespace Deno {
* handleHttp(conn);
* }
* ```
+ *
+ * @category HTTP Server
*/
export function serveHttp(conn: Conn): HttpConn;
+ /** @category Web Sockets */
export interface WebSocketUpgrade {
response: Response;
socket: WebSocket;
}
+ /** @category Web Sockets */
export interface UpgradeWebSocketOptions {
protocol?: string;
/**
@@ -2941,6 +3286,8 @@ declare namespace Deno {
*
* This operation does not yet consume the request or open the websocket. This
* only happens once the returned response has been passed to `respondWith`.
+ *
+ * @category Web Sockets
*/
export function upgradeWebSocket(
request: Request,
@@ -2961,11 +3308,17 @@ declare namespace Deno {
* Deno.kill(p.pid, "SIGINT");
* ```
*
- * Requires `allow-run` permission. */
+ * Requires `allow-run` permission.
+ *
+ * @category Sub Process
+ */
export function kill(pid: number, signo: Signal): void;
/** The type of the resource record.
- * Only the listed types are supported currently. */
+ * Only the listed types are supported currently.
+ *
+ * @category Network
+ */
export type RecordType =
| "A"
| "AAAA"
@@ -2980,6 +3333,7 @@ declare namespace Deno {
| "SRV"
| "TXT";
+ /** @category Network */
export interface ResolveDnsOptions {
/** The name server to be used for lookups.
* If not specified, defaults to the system configuration e.g. `/etc/resolv.conf` on Unix. */
@@ -2992,20 +3346,32 @@ declare namespace Deno {
};
}
- /** If `resolveDns` is called with "CAA" record type specified, it will return an array of this interface. */
+ /** If `resolveDns` is called with "CAA" record type specified, it will return
+ * an array of this interface.
+ *
+ * @category Network
+ */
export interface CAARecord {
critical: boolean;
tag: string;
value: string;
}
- /** If `resolveDns` is called with "MX" record type specified, it will return an array of this interface. */
+ /** If `resolveDns` is called with "MX" record type specified, it will return
+ * an array of this interface.
+ *
+ * @category Network
+ */
export interface MXRecord {
preference: number;
exchange: string;
}
- /** If `resolveDns` is called with "NAPTR" record type specified, it will return an array of this interface. */
+ /** If `resolveDns` is called with "NAPTR" record type specified, it will
+ * return an array of this interface.
+ *
+ * @category Network
+ */
export interface NAPTRRecord {
order: number;
preference: number;
@@ -3015,7 +3381,11 @@ declare namespace Deno {
replacement: string;
}
- /** If `resolveDns` is called with "SOA" record type specified, it will return an array of this interface. */
+ /** If `resolveDns` is called with "SOA" record type specified, it will return
+ * an array of this interface.
+ *
+ * @category Network
+ */
export interface SOARecord {
mname: string;
rname: string;
@@ -3026,7 +3396,11 @@ declare namespace Deno {
minimum: number;
}
- /** If `resolveDns` is called with "SRV" record type specified, it will return an array of this interface. */
+ /** If `resolveDns` is called with "SRV" record type specified, it will return
+ * an array of this interface.
+ *
+ * @category Network
+ */
export interface SRVRecord {
priority: number;
weight: number;
@@ -3034,42 +3408,49 @@ declare namespace Deno {
target: string;
}
+ /** @category Network */
export function resolveDns(
query: string,
recordType: "A" | "AAAA" | "ANAME" | "CNAME" | "NS" | "PTR",
options?: ResolveDnsOptions,
): Promise<string[]>;
+ /** @category Network */
export function resolveDns(
query: string,
recordType: "CAA",
options?: ResolveDnsOptions,
): Promise<CAARecord[]>;
+ /** @category Network */
export function resolveDns(
query: string,
recordType: "MX",
options?: ResolveDnsOptions,
): Promise<MXRecord[]>;
+ /** @category Network */
export function resolveDns(
query: string,
recordType: "NAPTR",
options?: ResolveDnsOptions,
): Promise<NAPTRRecord[]>;
+ /** @category Network */
export function resolveDns(
query: string,
recordType: "SOA",
options?: ResolveDnsOptions,
): Promise<SOARecord[]>;
+ /** @category Network */
export function resolveDns(
query: string,
recordType: "SRV",
options?: ResolveDnsOptions,
): Promise<SRVRecord[]>;
+ /** @category Network */
export function resolveDns(
query: string,
recordType: "TXT",
@@ -3092,6 +3473,8 @@ declare namespace Deno {
* ```
*
* Requires `allow-net` permission.
+ *
+ * @category Network
*/
export function resolveDns(
query: string,