// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
/* eslint-disable @typescript-eslint/no-explicit-any */
/* eslint-disable @typescript-eslint/no-empty-interface */
///
///
declare namespace Deno {
// @url js/os.d.ts
/** The current process id of the runtime. */
export let pid: number;
/** Reflects the NO_COLOR environment variable: https://no-color.org/ */
export let noColor: boolean;
/** Check if running in terminal.
*
* console.log(Deno.isTTY().stdout);
*/
export function isTTY(): {
stdin: boolean;
stdout: boolean;
stderr: boolean;
};
/** Get the hostname.
* Requires the `--allow-env` flag.
*
* console.log(Deno.hostname());
*/
export function hostname(): string;
/** Exit the Deno process with optional exit code. */
export function exit(code?: number): never;
/** Returns a snapshot of the environment variables at invocation. Mutating a
* property in the object will set that variable in the environment for
* the process. The environment object will only accept `string`s
* as values.
*
* const myEnv = Deno.env();
* console.log(myEnv.SHELL);
* myEnv.TEST_VAR = "HELLO";
* const newEnv = Deno.env();
* console.log(myEnv.TEST_VAR == newEnv.TEST_VAR);
*/
export function env(): {
[index: string]: string;
};
/** Returns the value of an environment variable at invocation.
* If the variable is not present, `undefined` will be returned.
*
* const myEnv = Deno.env();
* console.log(myEnv.SHELL);
* myEnv.TEST_VAR = "HELLO";
* const newEnv = Deno.env();
* console.log(myEnv.TEST_VAR == newEnv.TEST_VAR);
*/
export function env(key: string): string | undefined;
export type DirKind =
| "home"
| "cache"
| "config"
| "executable"
| "data"
| "data_local"
| "audio"
| "desktop"
| "document"
| "download"
| "font"
| "picture"
| "public"
| "template"
| "video";
/**
* Returns the user and platform specific directories.
* Requires the `--allow-env` flag.
* Returns null if there is no applicable directory or if any other error
* occurs.
*
* Argument values: "home", "cache", "config", "executable", "data",
* "data_local", "audio", "desktop", "document", "download", "font", "picture",
* "public", "template", "video"
*
* "cache"
* |Platform | Value | Example |
* | ------- | ----------------------------------- | ---------------------------- |
* | Linux | `$XDG_CACHE_HOME` or `$HOME`/.cache | /home/alice/.cache |
* | macOS | `$HOME`/Library/Caches | /Users/Alice/Library/Caches |
* | Windows | `{FOLDERID_LocalAppData}` | C:\Users\Alice\AppData\Local |
*
* "config"
* |Platform | Value | Example |
* | ------- | ------------------------------------- | -------------------------------- |
* | Linux | `$XDG_CONFIG_HOME` or `$HOME`/.config | /home/alice/.config |
* | macOS | `$HOME`/Library/Preferences | /Users/Alice/Library/Preferences |
* | Windows | `{FOLDERID_RoamingAppData}` | C:\Users\Alice\AppData\Roaming |
*
* "executable"
* |Platform | Value | Example |
* | ------- | --------------------------------------------------------------- | -----------------------|
* | Linux | `XDG_BIN_HOME` or `$XDG_DATA_HOME`/../bin or `$HOME`/.local/bin | /home/alice/.local/bin |
* | macOS | - | - |
* | Windows | - | - |
*
* "data"
* |Platform | Value | Example |
* | ------- | ---------------------------------------- | ---------------------------------------- |
* | Linux | `$XDG_DATA_HOME` or `$HOME`/.local/share | /home/alice/.local/share |
* | macOS | `$HOME`/Library/Application Support | /Users/Alice/Library/Application Support |
* | Windows | `{FOLDERID_RoamingAppData}` | C:\Users\Alice\AppData\Roaming |
*
* "data_local"
* |Platform | Value | Example |
* | ------- | ---------------------------------------- | ---------------------------------------- |
* | Linux | `$XDG_DATA_HOME` or `$HOME`/.local/share | /home/alice/.local/share |
* | macOS | `$HOME`/Library/Application Support | /Users/Alice/Library/Application Support |
* | Windows | `{FOLDERID_LocalAppData}` | C:\Users\Alice\AppData\Local |
*
* "audio"
* |Platform | Value | Example |
* | ------- | ------------------ | -------------------- |
* | Linux | `XDG_MUSIC_DIR` | /home/alice/Music |
* | macOS | `$HOME`/Music | /Users/Alice/Music |
* | Windows | `{FOLDERID_Music}` | C:\Users\Alice\Music |
*
* "desktop"
* |Platform | Value | Example |
* | ------- | -------------------- | ---------------------- |
* | Linux | `XDG_DESKTOP_DIR` | /home/alice/Desktop |
* | macOS | `$HOME`/Desktop | /Users/Alice/Desktop |
* | Windows | `{FOLDERID_Desktop}` | C:\Users\Alice\Desktop |
*
* "document"
* |Platform | Value | Example |
* | ------- | ---------------------- | ------------------------ |
* | Linux | `XDG_DOCUMENTS_DIR` | /home/alice/Documents |
* | macOS | `$HOME`/Documents | /Users/Alice/Documents |
* | Windows | `{FOLDERID_Documents}` | C:\Users\Alice\Documents |
*
* "download"
* |Platform | Value | Example |
* | ------- | ---------------------- | ------------------------ |
* | Linux | `XDG_DOWNLOAD_DIR` | /home/alice/Downloads |
* | macOS | `$HOME`/Downloads | /Users/Alice/Downloads |
* | Windows | `{FOLDERID_Downloads}` | C:\Users\Alice\Downloads |
*
* "font"
* |Platform | Value | Example |
* | ------- | ---------------------------------------------------- | ------------------------------ |
* | Linux | `$XDG_DATA_HOME`/fonts or `$HOME`/.local/share/fonts | /home/alice/.local/share/fonts |
* | macOS | `$HOME/Library/Fonts` | /Users/Alice/Library/Fonts |
* | Windows | – | – |
*
* "picture"
* |Platform | Value | Example |
* | ------- | --------------------- | ----------------------- |
* | Linux | `XDG_PICTURES_DIR` | /home/alice/Pictures |
* | macOS | `$HOME`/Pictures | /Users/Alice/Pictures |
* | Windows | `{FOLDERID_Pictures}` | C:\Users\Alice\Pictures |
*
* "public"
* |Platform | Value | Example |
* | ------- | --------------------- | ------------------- |
* | Linux | `XDG_PUBLICSHARE_DIR` | /home/alice/Public |
* | macOS | `$HOME`/Public | /Users/Alice/Public |
* | Windows | `{FOLDERID_Public}` | C:\Users\Public |
*
* "template"
* |Platform | Value | Example |
* | ------- | ---------------------- | ---------------------------------------------------------- |
* | Linux | `XDG_TEMPLATES_DIR` | /home/alice/Templates |
* | macOS | – | – |
* | Windows | `{FOLDERID_Templates}` | C:\Users\Alice\AppData\Roaming\Microsoft\Windows\Templates |
*
* "video"
* |Platform | Value | Example |
* | ------- | ------------------- | --------------------- |
* | Linux | `XDG_VIDEOS_DIR` | /home/alice/Videos |
* | macOS | `$HOME`/Movies | /Users/Alice/Movies |
* | Windows | `{FOLDERID_Videos}` | C:\Users\Alice\Videos |
*/
export function dir(kind: DirKind): string | null;
/**
* Returns the path to the current deno executable.
* Requires the `--allow-env` flag.
*/
export function execPath(): string;
// @url js/dir.d.ts
/**
* `cwd()` Return a string representing the current working directory.
* If the current directory can be reached via multiple paths
* (due to symbolic links), `cwd()` may return
* any one of them.
* throws `NotFound` exception if directory not available
*/
export function cwd(): string;
/**
* `chdir()` Change the current working directory to path.
* throws `NotFound` exception if directory not available
*/
export function chdir(directory: string): void;
// @url js/io.d.ts
export const EOF: unique symbol;
export type EOF = typeof EOF;
export enum SeekMode {
SEEK_START = 0,
SEEK_CURRENT = 1,
SEEK_END = 2
}
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 encountered.
* Even if `read()` returns `n` < `p.byteLength`, it may use all of `p` as
* scratch space during the call. If some data is available but not
* `p.byteLength` bytes, `read()` conventionally returns what is available
* instead of waiting for more.
*
* When `read()` encounters end-of-file condition, it returns EOF symbol.
*
* When `read()` encounters an error, it rejects with an error.
*
* Callers should always process the `n` > `0` bytes returned before
* considering the EOF. Doing so correctly handles I/O errors that happen
* after reading some bytes and also both of the allowed EOF behaviors.
*
* Implementations must not retain `p`.
*/
read(p: Uint8Array): Promise;
}
export interface SyncReader {
readSync(p: Uint8Array): number | EOF;
}
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` <=
* `p.byteLength`) and any error encountered that caused the write to stop
* early. `write()` must return a non-null error if it returns `n` <
* `p.byteLength`. write() must not modify the slice data, even temporarily.
*
* Implementations must not retain `p`.
*/
write(p: Uint8Array): Promise;
}
export interface SyncWriter {
writeSync(p: Uint8Array): number;
}
export interface Closer {
close(): void;
}
export interface Seeker {
/** Seek sets the offset for the next `read()` or `write()` to offset,
* interpreted according to `whence`: `SeekStart` means relative to the start
* of the file, `SeekCurrent` means relative to the current offset, and
* `SeekEnd` means relative to the end. Seek returns the new offset relative
* to the start of the file and an error, if any.
*
* Seeking to an offset before the start of the file is an error. Seeking to
* any positive offset is legal, but the behavior of subsequent I/O operations
* on the underlying object is implementation-dependent.
*/
seek(offset: number, whence: SeekMode): Promise;
}
export interface SyncSeeker {
seekSync(offset: number, whence: SeekMode): void;
}
export interface ReadCloser extends Reader, Closer {}
export interface WriteCloser extends Writer, Closer {}
export interface ReadSeeker extends Reader, Seeker {}
export interface WriteSeeker extends Writer, Seeker {}
export interface ReadWriteCloser extends Reader, Writer, Closer {}
export interface ReadWriteSeeker extends Reader, Writer, Seeker {}
/** Copies from `src` to `dst` until either `EOF` is reached on `src`
* or an error occurs. It returns the number of bytes copied and the first
* error encountered while copying, if any.
*
* Because `copy()` is defined to read from `src` until `EOF`, it does not
* treat an `EOF` from `read()` as an error to be reported.
*/
export function copy(dst: Writer, src: Reader): Promise;
/** Turns `r` into async iterator.
*
* for await (const chunk of toAsyncIterator(reader)) {
* console.log(chunk)
* }
*/
export function toAsyncIterator(r: Reader): AsyncIterableIterator;
// @url js/files.d.ts
/** Open a file and return an instance of the `File` object
* synchronously.
*
* const file = Deno.openSync("/foo/bar.txt");
*/
export function openSync(filename: string, mode?: OpenMode): File;
/** Open a file and return an instance of the `File` object.
*
* (async () => {
* const file = await Deno.open("/foo/bar.txt");
* })();
*/
export function open(filename: string, mode?: OpenMode): Promise;
/** Creates a file if none exists or truncates an existing file and returns
* an instance of the `File` object synchronously.
*
* const file = Deno.createSync("/foo/bar.txt");
*/
export function createSync(filename: string): File;
/** Creates a file if none exists or truncates an existing file and returns
* an instance of the `File` object.
*
* const file = await Deno.create("/foo/bar.txt");
*/
export function create(filename: string): Promise;
/** Read synchronously from a file ID into an array buffer.
*
* Return `number | EOF` for the operation.
*
* const file = Deno.openSync("/foo/bar.txt");
* const buf = new Uint8Array(100);
* const nread = Deno.readSync(file.rid, buf);
* const text = new TextDecoder().decode(buf);
*
*/
export function readSync(rid: number, p: Uint8Array): number | EOF;
/** Read from a file ID into an array buffer.
*
* Resolves with the `number | EOF` for the operation.
*
* (async () => {
* const file = await Deno.open("/foo/bar.txt");
* const buf = new Uint8Array(100);
* const nread = await Deno.read(file.rid, buf);
* const text = new TextDecoder().decode(buf);
* })();
*/
export function read(rid: number, p: Uint8Array): Promise;
/** Write synchronously to the file ID the contents of the array buffer.
*
* Resolves with the number of bytes written.
*
* const encoder = new TextEncoder();
* const data = encoder.encode("Hello world\n");
* const file = Deno.openSync("/foo/bar.txt");
* Deno.writeSync(file.rid, data);
*/
export function writeSync(rid: number, p: Uint8Array): number;
/** Write to the file ID the contents of the array buffer.
*
* Resolves with the number of bytes written.
*
* (async () => {
* const encoder = new TextEncoder();
* const data = encoder.encode("Hello world\n");
* const file = await Deno.open("/foo/bar.txt");
* await Deno.write(file.rid, data);
* })();
*
*/
export function write(rid: number, p: Uint8Array): Promise;
/** Seek a file ID synchronously to the given offset under mode given by `whence`.
*
* const file = Deno.openSync("/foo/bar.txt");
* Deno.seekSync(file.rid, 0, 0);
*/
export function seekSync(rid: number, offset: number, whence: SeekMode): void;
/** Seek a file ID to the given offset under mode given by `whence`.
*
* (async () => {
* const file = await Deno.open("/foo/bar.txt");
* await Deno.seek(file.rid, 0, 0);
* })();
*/
export function seek(
rid: number,
offset: number,
whence: SeekMode
): Promise;
/** Close the file ID. */
export function close(rid: number): void;
/** The Deno abstraction for reading and writing files. */
export class File
implements
Reader,
SyncReader,
Writer,
SyncWriter,
Seeker,
SyncSeeker,
Closer {
readonly rid: number;
constructor(rid: number);
write(p: Uint8Array): Promise;
writeSync(p: Uint8Array): number;
read(p: Uint8Array): Promise;
readSync(p: Uint8Array): number | EOF;
seek(offset: number, whence: SeekMode): Promise;
seekSync(offset: number, whence: SeekMode): void;
close(): void;
}
/** An instance of `File` for stdin. */
export const stdin: File;
/** An instance of `File` for stdout. */
export const stdout: File;
/** An instance of `File` for stderr. */
export const stderr: File;
export type OpenMode =
| "r"
/** Read-write. Start at beginning of file. */
| "r+"
/** Write-only. Opens and truncates existing file or creates new one for
* writing only.
*/
| "w"
/** Read-write. Opens and truncates existing file or creates new one for
* writing and reading.
*/
| "w+"
/** Write-only. Opens existing file or creates new one. Each write appends
* content to the end of file.
*/
| "a"
/** Read-write. Behaves like "a" and allows to read from file. */
| "a+"
/** Write-only. Exclusive create - creates new file only if one doesn't exist
* already.
*/
| "x"
/** Read-write. Behaves like `x` and allows to read from file. */
| "x+";
// @url js/buffer.d.ts
/** A Buffer is a variable-sized buffer of bytes with read() and write()
* methods. Based on https://golang.org/pkg/bytes/#Buffer
*/
export class Buffer implements Reader, SyncReader, Writer, SyncWriter {
private buf;
private off;
constructor(ab?: ArrayBuffer);
/** bytes() returns a slice holding the unread portion of the buffer.
* The slice is valid for use only until the next buffer modification (that
* is, only until the next call to a method like read(), write(), reset(), or
* truncate()). The slice aliases the buffer content at least until the next
* buffer modification, so immediate changes to the slice will affect the
* result of future reads.
*/
bytes(): Uint8Array;
/** toString() returns the contents of the unread portion of the buffer
* as a string. Warning - if multibyte characters are present when data is
* flowing through the buffer, this method may result in incorrect strings
* due to a character being split.
*/
toString(): string;
/** empty() returns whether the unread portion of the buffer is empty. */
empty(): boolean;
/** length is a getter that returns the number of bytes of the unread
* portion of the buffer
*/
readonly length: number;
/** Returns the capacity of the buffer's underlying byte slice, that is,
* the total space allocated for the buffer's data.
*/
readonly capacity: number;
/** truncate() discards all but the first n unread bytes from the buffer but
* continues to use the same allocated storage. It throws if n is negative or
* greater than the length of the buffer.
*/
truncate(n: number): void;
/** reset() resets the buffer to be empty, but it retains the underlying
* storage for use by future writes. reset() is the same as truncate(0)
*/
reset(): void;
/** _tryGrowByReslice() is a version of grow for the fast-case
* where the internal buffer only needs to be resliced. It returns the index
* where bytes should be written and whether it succeeded.
* It returns -1 if a reslice was not needed.
*/
private _tryGrowByReslice;
private _reslice;
/** readSync() reads the next len(p) bytes from the buffer or until the buffer
* is drained. The return value n is the number of bytes read. If the
* buffer has no data to return, eof in the response will be true.
*/
readSync(p: Uint8Array): number | EOF;
read(p: Uint8Array): Promise;
writeSync(p: Uint8Array): number;
write(p: Uint8Array): Promise;
/** _grow() grows the buffer to guarantee space for n more bytes.
* It returns the index where bytes should be written.
* If the buffer can't grow it will throw with ErrTooLarge.
*/
private _grow;
/** grow() grows the buffer's capacity, if necessary, to guarantee space for
* another n bytes. After grow(n), at least n bytes can be written to the
* buffer without another allocation. If n is negative, grow() will panic. If
* the buffer can't grow it will throw ErrTooLarge.
* Based on https://golang.org/pkg/bytes/#Buffer.Grow
*/
grow(n: number): void;
/** readFrom() reads data from r until EOF and appends it to the buffer,
* growing the buffer as needed. It returns the number of bytes read. If the
* buffer becomes too large, readFrom will panic with ErrTooLarge.
* Based on https://golang.org/pkg/bytes/#Buffer.ReadFrom
*/
readFrom(r: Reader): Promise;
/** Sync version of `readFrom`
*/
readFromSync(r: SyncReader): number;
}
/** Read `r` until EOF and return the content as `Uint8Array`.
*/
export function readAll(r: Reader): Promise;
/** Read synchronously `r` until EOF and return the content as `Uint8Array`.
*/
export function readAllSync(r: SyncReader): Uint8Array;
/** Write all the content of `arr` to `w`.
*/
export function writeAll(w: Writer, arr: Uint8Array): Promise;
/** Write synchronously all the content of `arr` to `w`.
*/
export function writeAllSync(w: SyncWriter, arr: Uint8Array): void;
// @url js/mkdir.d.ts
export interface MkdirOption {
recursive?: boolean;
mode?: number;
}
/** Creates a new directory with the specified path synchronously.
* If `recursive` is set to true, nested directories will be created (also known
* as "mkdir -p").
* `mode` sets permission bits (before umask) on UNIX and does nothing on
* Windows.
*
* Deno.mkdirSync("new_dir");
* Deno.mkdirSync("nested/directories", { recursive: true });
*/
export function mkdirSync(path: string, options?: MkdirOption): void;
/** Deprecated */
export function mkdirSync(
path: string,
recursive?: boolean,
mode?: number
): void;
/** Creates a new directory with the specified path.
* If `recursive` is set to true, nested directories will be created (also known
* as "mkdir -p").
* `mode` sets permission bits (before umask) on UNIX and does nothing on
* Windows.
*
* await Deno.mkdir("new_dir");
* await Deno.mkdir("nested/directories", { recursive: true });
*/
export function mkdir(path: string, options?: MkdirOption): Promise;
/** Deprecated */
export function mkdir(
path: string,
recursive?: boolean,
mode?: number
): Promise;
// @url js/make_temp_dir.d.ts
export interface MakeTempDirOptions {
dir?: string;
prefix?: string;
suffix?: string;
}
/** makeTempDirSync is the synchronous version of `makeTempDir`.
*
* const tempDirName0 = Deno.makeTempDirSync();
* const tempDirName1 = Deno.makeTempDirSync({ prefix: 'my_temp' });
*/
export function makeTempDirSync(options?: MakeTempDirOptions): string;
/** makeTempDir creates a new temporary directory in the directory `dir`, its
* name beginning with `prefix` and ending with `suffix`.
* It returns the full path to the newly created directory.
* If `dir` is unspecified, tempDir uses the default directory for temporary
* files. Multiple programs calling tempDir simultaneously will not choose the
* same directory. It is the caller's responsibility to remove the directory
* when no longer needed.
*
* const tempDirName0 = await Deno.makeTempDir();
* const tempDirName1 = await Deno.makeTempDir({ prefix: 'my_temp' });
*/
export function makeTempDir(options?: MakeTempDirOptions): Promise;
// @url js/chmod.d.ts
/** Changes the permission of a specific file/directory of specified path
* synchronously.
*
* Deno.chmodSync("/path/to/file", 0o666);
*/
export function chmodSync(path: string, mode: number): void;
/** Changes the permission of a specific file/directory of specified path.
*
* await Deno.chmod("/path/to/file", 0o666);
*/
export function chmod(path: string, mode: number): Promise;
// @url js/chown.d.ts
/**
* Change owner of a regular file or directory synchronously. Unix only at the moment.
* @param path path to the file
* @param uid user id of the new owner
* @param gid group id of the new owner
*/
export function chownSync(path: string, uid: number, gid: number): void;
/**
* Change owner of a regular file or directory asynchronously. Unix only at the moment.
* @param path path to the file
* @param uid user id of the new owner
* @param gid group id of the new owner
*/
export function chown(path: string, uid: number, gid: number): Promise;
// @url js/utime.d.ts
/** Synchronously changes the access and modification times of a file system
* object referenced by `filename`. Given times are either in seconds
* (Unix epoch time) or as `Date` objects.
*
* Deno.utimeSync("myfile.txt", 1556495550, new Date());
*/
export function utimeSync(
filename: string,
atime: number | Date,
mtime: number | Date
): void;
/** Changes the access and modification times of a file system object
* referenced by `filename`. Given times are either in seconds
* (Unix epoch time) or as `Date` objects.
*
* await Deno.utime("myfile.txt", 1556495550, new Date());
*/
export function utime(
filename: string,
atime: number | Date,
mtime: number | Date
): Promise;
// @url js/remove.d.ts
export interface RemoveOption {
recursive?: boolean;
}
/** Removes the named file or directory synchronously. Would throw
* error if permission denied, not found, or directory not empty if `recursive`
* set to false.
* `recursive` is set to false by default.
*
* Deno.removeSync("/path/to/dir/or/file", {recursive: false});
*/
export function removeSync(path: string, options?: RemoveOption): void;
/** Removes the named file or directory. Would throw error if
* permission denied, not found, or directory not empty if `recursive` set
* to false.
* `recursive` is set to false by default.
*
* await Deno.remove("/path/to/dir/or/file", {recursive: false});
*/
export function remove(path: string, options?: RemoveOption): Promise;
// @url js/rename.d.ts
/** Synchronously renames (moves) `oldpath` to `newpath`. If `newpath` already
* exists and is not a directory, `renameSync()` replaces it. OS-specific
* restrictions may apply when `oldpath` and `newpath` are in different
* directories.
*
* Deno.renameSync("old/path", "new/path");
*/
export function renameSync(oldpath: string, newpath: string): void;
/** Renames (moves) `oldpath` to `newpath`. If `newpath` already exists and is
* not a directory, `rename()` replaces it. OS-specific restrictions may apply
* when `oldpath` and `newpath` are in different directories.
*
* await Deno.rename("old/path", "new/path");
*/
export function rename(oldpath: string, newpath: string): Promise;
// @url js/read_file.d.ts
/** Read the entire contents of a file synchronously.
*
* const decoder = new TextDecoder("utf-8");
* const data = Deno.readFileSync("hello.txt");
* console.log(decoder.decode(data));
*/
export function readFileSync(filename: string): Uint8Array;
/** Read the entire contents of a file.
*
* const decoder = new TextDecoder("utf-8");
* const data = await Deno.readFile("hello.txt");
* console.log(decoder.decode(data));
*/
export function readFile(filename: string): Promise;
// @url js/file_info.d.ts
/** A FileInfo describes a file and is returned by `stat`, `lstat`,
* `statSync`, `lstatSync`.
*/
export interface FileInfo {
/** The size of the file, in bytes. */
len: number;
/** The last modification time of the file. This corresponds to the `mtime`
* field from `stat` on Unix and `ftLastWriteTime` on Windows. This may not
* be available on all platforms.
*/
modified: number | null;
/** The last access time of the file. This corresponds to the `atime`
* field from `stat` on Unix and `ftLastAccessTime` on Windows. This may not
* be available on all platforms.
*/
accessed: number | null;
/** The last access time of the file. This corresponds to the `birthtime`
* field from `stat` on Unix and `ftCreationTime` on Windows. This may not
* be available on all platforms.
*/
created: number | null;
/** The file or directory name. */
name: string | null;
/** ID of the device containing the file. Unix only. */
dev: number | null;
/** Inode number. Unix only. */
ino: number | null;
/** The underlying raw st_mode bits that contain the standard Unix permissions
* for this file/directory. TODO Match behavior with Go on windows for mode.
*/
mode: number | null;
/** Number of hard links pointing to this file. Unix only. */
nlink: number | null;
/** User ID of the owner of this file. Unix only. */
uid: number | null;
/** User ID of the owner of this file. Unix only. */
gid: number | null;
/** Device ID of this file. Unix only. */
rdev: number | null;
/** Blocksize for filesystem I/O. Unix only. */
blksize: number | null;
/** Number of blocks allocated to the file, in 512-byte units. Unix only. */
blocks: number | null;
/** Returns whether this is info for a regular file. This result is mutually
* exclusive to `FileInfo.isDirectory` and `FileInfo.isSymlink`.
*/
isFile(): boolean;
/** Returns whether this is info for a regular directory. This result is
* mutually exclusive to `FileInfo.isFile` and `FileInfo.isSymlink`.
*/
isDirectory(): boolean;
/** Returns whether this is info for a symlink. This result is
* mutually exclusive to `FileInfo.isFile` and `FileInfo.isDirectory`.
*/
isSymlink(): boolean;
}
// @url js/realpath.d.ts
/** Returns absolute normalized path with symbolic links resolved
* synchronously.
*
* const realPath = Deno.realpathSync("./some/path");
*/
export function realpathSync(path: string): string;
/** Returns absolute normalized path with symbolic links resolved.
*
* const realPath = await Deno.realpath("./some/path");
*/
export function realpath(path: string): Promise;
// @url js/read_dir.d.ts
/** Reads the directory given by path and returns a list of file info
* synchronously.
*
* const files = Deno.readDirSync("/");
*/
export function readDirSync(path: string): FileInfo[];
/** Reads the directory given by path and returns a list of file info.
*
* const files = await Deno.readDir("/");
*/
export function readDir(path: string): Promise;
// @url js/copy_file.d.ts
/** Copies the contents of a file to another by name synchronously.
* Creates a new file if target does not exists, and if target exists,
* overwrites original content of the target file.
*
* It would also copy the permission of the original file
* to the destination.
*
* Deno.copyFileSync("from.txt", "to.txt");
*/
export function copyFileSync(from: string, to: string): void;
/** Copies the contents of a file to another by name.
*
* Creates a new file if target does not exists, and if target exists,
* overwrites original content of the target file.
*
* It would also copy the permission of the original file
* to the destination.
*
* await Deno.copyFile("from.txt", "to.txt");
*/
export function copyFile(from: string, to: string): Promise;
// @url js/read_link.d.ts
/** Returns the destination of the named symbolic link synchronously.
*
* const targetPath = Deno.readlinkSync("symlink/path");
*/
export function readlinkSync(name: string): string;
/** Returns the destination of the named symbolic link.
*
* const targetPath = await Deno.readlink("symlink/path");
*/
export function readlink(name: string): Promise;
// @url js/stat.d.ts
interface StatResponse {
isFile: boolean;
isSymlink: boolean;
len: number;
modified: number;
accessed: number;
created: number;
name: string | null;
dev: number;
ino: number;
mode: number;
nlink: number;
uid: number;
gid: number;
rdev: number;
blksize: number;
blocks: number;
}
/** Queries the file system for information on the path provided. If the given
* path is a symlink information about the symlink will be returned.
*
* const fileInfo = await Deno.lstat("hello.txt");
* assert(fileInfo.isFile());
*/
export function lstat(filename: string): Promise;
/** Queries the file system for information on the path provided synchronously.
* If the given path is a symlink information about the symlink will be
* returned.
*
* const fileInfo = Deno.lstatSync("hello.txt");
* assert(fileInfo.isFile());
*/
export function lstatSync(filename: string): FileInfo;
/** Queries the file system for information on the path provided. `stat` Will
* always follow symlinks.
*
* const fileInfo = await Deno.stat("hello.txt");
* assert(fileInfo.isFile());
*/
export function stat(filename: string): Promise;
/** Queries the file system for information on the path provided synchronously.
* `statSync` Will always follow symlinks.
*
* const fileInfo = Deno.statSync("hello.txt");
* assert(fileInfo.isFile());
*/
export function statSync(filename: string): FileInfo;
// @url js/link.d.ts
/** Synchronously creates `newname` as a hard link to `oldname`.
*
* Deno.linkSync("old/name", "new/name");
*/
export function linkSync(oldname: string, newname: string): void;
/** Creates `newname` as a hard link to `oldname`.
*
* await Deno.link("old/name", "new/name");
*/
export function link(oldname: string, newname: string): Promise;
// @url js/symlink.d.ts
/** Synchronously creates `newname` as a symbolic link to `oldname`. The type
* argument can be set to `dir` or `file` and is only available on Windows
* (ignored on other platforms).
*
* Deno.symlinkSync("old/name", "new/name");
*/
export function symlinkSync(
oldname: string,
newname: string,
type?: string
): void;
/** Creates `newname` as a symbolic link to `oldname`. The type argument can be
* set to `dir` or `file` and is only available on Windows (ignored on other
* platforms).
*
* await Deno.symlink("old/name", "new/name");
*/
export function symlink(
oldname: string,
newname: string,
type?: string
): Promise;
// @url js/write_file.d.ts
/** Options for writing to a file.
* `perm` would change the file's permission if set.
* `create` decides if the file should be created if not exists (default: true)
* `append` decides if the file should be appended (default: false)
*/
export interface WriteFileOptions {
perm?: number;
create?: boolean;
append?: boolean;
}
/** Write a new file, with given filename and data synchronously.
*
* const encoder = new TextEncoder();
* const data = encoder.encode("Hello world\n");
* Deno.writeFileSync("hello.txt", data);
*/
export function writeFileSync(
filename: string,
data: Uint8Array,
options?: WriteFileOptions
): void;
/** Write a new file, with given filename and data.
*
* const encoder = new TextEncoder();
* const data = encoder.encode("Hello world\n");
* await Deno.writeFile("hello.txt", data);
*/
export function writeFile(
filename: string,
data: Uint8Array,
options?: WriteFileOptions
): Promise;
// @url js/error_stack.d.ts
interface Location {
/** The full url for the module, e.g. `file://some/file.ts` or
* `https://some/file.ts`. */
filename: string;
/** The line number in the file. It is assumed to be 1-indexed. */
line: number;
/** The column number in the file. It is assumed to be 1-indexed. */
column: number;
}
/** Given a current location in a module, lookup the source location and
* return it.
*
* When Deno transpiles code, it keep source maps of the transpiled code. This
* function can be used to lookup the original location. This is automatically
* done when accessing the `.stack` of an error, or when an uncaught error is
* logged. This function can be used to perform the lookup for creating better
* error handling.
*
* **Note:** `line` and `column` are 1 indexed, which matches display
* expectations, but is not typical of most index numbers in Deno.
*
* An example:
*
* const orig = Deno.applySourceMap({
* location: "file://my/module.ts",
* line: 5,
* column: 15
* });
* console.log(`${orig.filename}:${orig.line}:${orig.column}`);
*
*/
export function applySourceMap(location: Location): Location;
// @url js/errors.d.ts
/** A Deno specific error. The `kind` property is set to a specific error code
* which can be used to in application logic.
*
* try {
* somethingThatMightThrow();
* } catch (e) {
* if (
* e instanceof Deno.DenoError &&
* e.kind === Deno.ErrorKind.Overflow
* ) {
* console.error("Overflow error!");
* }
* }
*
*/
export class DenoError extends Error {
readonly kind: T;
constructor(kind: T, msg: string);
}
export enum ErrorKind {
NoError = 0,
NotFound = 1,
PermissionDenied = 2,
ConnectionRefused = 3,
ConnectionReset = 4,
ConnectionAborted = 5,
NotConnected = 6,
AddrInUse = 7,
AddrNotAvailable = 8,
BrokenPipe = 9,
AlreadyExists = 10,
WouldBlock = 11,
InvalidInput = 12,
InvalidData = 13,
TimedOut = 14,
Interrupted = 15,
WriteZero = 16,
Other = 17,
UnexpectedEof = 18,
BadResource = 19,
CommandFailed = 20,
EmptyHost = 21,
IdnaError = 22,
InvalidPort = 23,
InvalidIpv4Address = 24,
InvalidIpv6Address = 25,
InvalidDomainCharacter = 26,
RelativeUrlWithoutBase = 27,
RelativeUrlWithCannotBeABaseBase = 28,
SetHostOnCannotBeABaseUrl = 29,
Overflow = 30,
HttpUser = 31,
HttpClosed = 32,
HttpCanceled = 33,
HttpParse = 34,
HttpOther = 35,
TooLarge = 36,
InvalidUri = 37,
InvalidSeekMode = 38,
OpNotAvailable = 39,
WorkerInitFailed = 40,
UnixError = 41,
NoAsyncSupport = 42,
NoSyncSupport = 43,
ImportMapError = 44,
InvalidPath = 45,
ImportPrefixMissing = 46,
UnsupportedFetchScheme = 47,
TooManyRedirects = 48,
Diagnostic = 49,
JSError = 50
}
// @url js/permissions.d.ts
/** Permissions as granted by the caller
* See: https://w3c.github.io/permissions/#permission-registry
*/
export type PermissionName =
| "run"
| "read"
| "write"
| "net"
| "env"
| "plugin"
| "hrtime";
/** https://w3c.github.io/permissions/#status-of-a-permission */
export type PermissionState = "granted" | "denied" | "prompt";
interface RunPermissionDescriptor {
name: "run";
}
interface ReadWritePermissionDescriptor {
name: "read" | "write";
path?: string;
}
interface NetPermissionDescriptor {
name: "net";
url?: string;
}
interface EnvPermissionDescriptor {
name: "env";
}
interface PluginPermissionDescriptor {
name: "plugin";
}
interface HrtimePermissionDescriptor {
name: "hrtime";
}
/** See: https://w3c.github.io/permissions/#permission-descriptor */
type PermissionDescriptor =
| RunPermissionDescriptor
| ReadWritePermissionDescriptor
| NetPermissionDescriptor
| EnvPermissionDescriptor
| PluginPermissionDescriptor
| HrtimePermissionDescriptor;
export class Permissions {
/** Queries the permission.
* const status = await Deno.permissions.query({ name: "read", path: "/etc" });
* if (status.state === "granted") {
* data = await Deno.readFile("/etc/passwd");
* }
*/
query(d: PermissionDescriptor): Promise;
/** Revokes the permission.
* const status = await Deno.permissions.revoke({ name: "run" });
* assert(status.state !== "granted")
*/
revoke(d: PermissionDescriptor): Promise;
/** Requests the permission.
* const status = await Deno.permissions.request({ name: "env" });
* if (status.state === "granted") {
* console.log(Deno.homeDir());
* } else {
* console.log("'env' permission is denied.");
* }
*/
request(desc: PermissionDescriptor): Promise;
}
export const permissions: Permissions;
/** https://w3c.github.io/permissions/#permissionstatus */
export class PermissionStatus {
state: PermissionState;
constructor(state: PermissionState);
}
// @url js/truncate.d.ts
/** Truncates or extends the specified file synchronously, updating the size of
* this file to become size.
*
* Deno.truncateSync("hello.txt", 10);
*/
export function truncateSync(name: string, len?: number): void;
/**
* Truncates or extends the specified file, updating the size of this file to
* become size.
*
* await Deno.truncate("hello.txt", 10);
*/
export function truncate(name: string, len?: number): Promise;
// @url js/plugins.d.ts
export interface AsyncHandler {
(msg: Uint8Array): void;
}
export interface PluginOp {
dispatch(
control: Uint8Array,
zeroCopy?: ArrayBufferView | null
): Uint8Array | null;
setAsyncHandler(handler: AsyncHandler): void;
}
export interface Plugin {
ops: {
[name: string]: PluginOp;
};
}
/** Open and initalize a plugin.
* Requires the `--allow-plugin` flag.
*
* const plugin = Deno.openPlugin("./path/to/some/plugin.so");
* const some_op = plugin.ops.some_op;
* const response = some_op.dispatch(new Uint8Array([1,2,3,4]));
* console.log(`Response from plugin ${response}`);
*/
export function openPlugin(filename: string): Plugin;
// @url js/net.d.ts
type Transport = "tcp";
interface Addr {
transport: Transport;
address: string;
}
export enum ShutdownMode {
// See http://man7.org/linux/man-pages/man2/shutdown.2.html
// Corresponding to SHUT_RD, SHUT_WR, SHUT_RDWR
Read = 0,
Write,
ReadWrite // unused
}
/** Shut down socket send and receive operations.
*
* Matches behavior of POSIX shutdown(3).
*
* const listener = Deno.listen({ port: 80 });
* const conn = await listener.accept();
* Deno.shutdown(conn.rid, Deno.ShutdownMode.Write);
*/
export function shutdown(rid: number, how: ShutdownMode): void;
/** A Listener is a generic network listener for stream-oriented protocols. */
export interface Listener extends AsyncIterator {
/** Waits for and resolves to the next connection to the `Listener`. */
accept(): Promise;
/** Close closes the listener. Any pending accept promises will be rejected
* with errors.
*/
close(): void;
/** Return the address of the `Listener`. */
addr(): Addr;
[Symbol.asyncIterator](): AsyncIterator;
}
export interface Conn extends Reader, Writer, Closer {
/** The local address of the connection. */
localAddr: string;
/** The remote address of the connection. */
remoteAddr: string;
/** The resource ID of the connection. */
rid: number;
/** Shuts down (`shutdown(2)`) the reading side of the TCP connection. Most
* callers should just use `close()`.
*/
closeRead(): void;
/** Shuts down (`shutdown(2)`) the writing side of the TCP connection. Most
* callers should just use `close()`.
*/
closeWrite(): void;
}
export interface ListenOptions {
port: number;
hostname?: string;
transport?: Transport;
}
/** Listen announces on the local transport address.
*
* @param options
* @param options.port The port to connect to. (Required.)
* @param options.hostname A literal IP address or host name that can be
* resolved to an IP address. If not specified, defaults to 0.0.0.0
* @param options.transport Defaults to "tcp". Later we plan to add "tcp4",
* "tcp6", "udp", "udp4", "udp6", "ip", "ip4", "ip6", "unix", "unixgram" and
* "unixpacket".
*
* Examples:
*
* listen({ port: 80 })
* listen({ hostname: "192.0.2.1", port: 80 })
* listen({ hostname: "[2001:db8::1]", port: 80 });
* listen({ hostname: "golang.org", port: 80, transport: "tcp" })
*/
export function listen(options: ListenOptions): Listener;
export interface ListenTLSOptions {
port: number;
hostname?: string;
transport?: Transport;
certFile: string;
keyFile: string;
}
/** Listen announces on the local transport address over TLS (transport layer security).
*
* @param options
* @param options.port The port to connect to. (Required.)
* @param options.hostname A literal IP address or host name that can be
* resolved to an IP address. If not specified, defaults to 0.0.0.0
* @param options.certFile Server certificate file
* @param options.keyFile Server public key file
*
* Examples:
*
* Deno.listenTLS({ port: 443, certFile: "./my_server.crt", keyFile: "./my_server.key" })
*/
export function listenTLS(options: ListenTLSOptions): Listener;
export interface DialOptions {
port: number;
hostname?: string;
transport?: Transport;
}
/** Dial connects to the address on the named transport.
*
* @param options
* @param options.port The port to connect to. (Required.)
* @param options.hostname A literal IP address or host name that can be
* resolved to an IP address. If not specified, defaults to 127.0.0.1
* @param options.transport Defaults to "tcp". Later we plan to add "tcp4",
* "tcp6", "udp", "udp4", "udp6", "ip", "ip4", "ip6", "unix", "unixgram" and
* "unixpacket".
*
* Examples:
*
* dial({ port: 80 })
* dial({ hostname: "192.0.2.1", port: 80 })
* dial({ hostname: "[2001:db8::1]", port: 80 });
* dial({ hostname: "golang.org", port: 80, transport: "tcp" })
*/
export function dial(options: DialOptions): Promise;
export interface DialTLSOptions {
port: number;
hostname?: string;
certFile?: string;
}
/**
* dialTLS establishes a secure connection over TLS (transport layer security).
*/
export function dialTLS(options: DialTLSOptions): Promise;
// @url js/metrics.d.ts
export interface Metrics {
opsDispatched: number;
opsCompleted: number;
bytesSentControl: number;
bytesSentData: number;
bytesReceived: number;
}
/** Receive metrics from the privileged side of Deno.
*
* > console.table(Deno.metrics())
* ┌──────────────────┬────────┐
* │ (index) │ Values │
* ├──────────────────┼────────┤
* │ opsDispatched │ 9 │
* │ opsCompleted │ 9 │
* │ bytesSentControl │ 504 │
* │ bytesSentData │ 0 │
* │ bytesReceived │ 856 │
* └──────────────────┴────────┘
*/
export function metrics(): Metrics;
// @url js/resources.d.ts
interface ResourceMap {
[rid: number]: string;
}
/** Returns a map of open _file like_ resource ids along with their string
* representation.
*/
export function resources(): ResourceMap;
// @url js/process.d.ts
/** How to handle subprocess stdio.
*
* "inherit" The default if unspecified. The child inherits from the
* corresponding parent descriptor.
*
* "piped" A new pipe should be arranged to connect the parent and child
* subprocesses.
*
* "null" This stream will be ignored. This is the equivalent of attaching the
* stream to /dev/null.
*/
type ProcessStdio = "inherit" | "piped" | "null";
export interface RunOptions {
args: string[];
cwd?: string;
env?: {
[key: string]: string;
};
stdout?: ProcessStdio | number;
stderr?: ProcessStdio | number;
stdin?: ProcessStdio | number;
}
/** Send a signal to process under given PID. Unix only at this moment.
* If pid is negative, the signal will be sent to the process group identified
* by -pid.
* Requires the `--allow-run` flag.
*/
export function kill(pid: number, signo: number): void;
export class Process {
readonly rid: number;
readonly pid: number;
readonly stdin?: WriteCloser;
readonly stdout?: ReadCloser;
readonly stderr?: ReadCloser;
status(): Promise;
/** Buffer the stdout and return it as Uint8Array after EOF.
* You must set stdout to "piped" when creating the process.
* This calls close() on stdout after its done.
*/
output(): Promise;
/** Buffer the stderr and return it as Uint8Array after EOF.
* You must set stderr to "piped" when creating the process.
* This calls close() on stderr after its done.
*/
stderrOutput(): Promise;
close(): void;
kill(signo: number): void;
}
export interface ProcessStatus {
success: boolean;
code?: number;
signal?: number;
}
/**
* Spawns new subprocess.
*
* Subprocess uses same working directory as parent process unless `opt.cwd`
* is specified.
*
* Environmental variables for subprocess can be specified using `opt.env`
* mapping.
*
* By default subprocess inherits stdio of parent process. To change that
* `opt.stdout`, `opt.stderr` and `opt.stdin` can be specified independently -
* they can be set to either `ProcessStdio` or `rid` of open file.
*/
export function run(opt: RunOptions): Process;
enum LinuxSignal {
SIGHUP = 1,
SIGINT = 2,
SIGQUIT = 3,
SIGILL = 4,
SIGTRAP = 5,
SIGABRT = 6,
SIGBUS = 7,
SIGFPE = 8,
SIGKILL = 9,
SIGUSR1 = 10,
SIGSEGV = 11,
SIGUSR2 = 12,
SIGPIPE = 13,
SIGALRM = 14,
SIGTERM = 15,
SIGSTKFLT = 16,
SIGCHLD = 17,
SIGCONT = 18,
SIGSTOP = 19,
SIGTSTP = 20,
SIGTTIN = 21,
SIGTTOU = 22,
SIGURG = 23,
SIGXCPU = 24,
SIGXFSZ = 25,
SIGVTALRM = 26,
SIGPROF = 27,
SIGWINCH = 28,
SIGIO = 29,
SIGPWR = 30,
SIGSYS = 31
}
enum MacOSSignal {
SIGHUP = 1,
SIGINT = 2,
SIGQUIT = 3,
SIGILL = 4,
SIGTRAP = 5,
SIGABRT = 6,
SIGEMT = 7,
SIGFPE = 8,
SIGKILL = 9,
SIGBUS = 10,
SIGSEGV = 11,
SIGSYS = 12,
SIGPIPE = 13,
SIGALRM = 14,
SIGTERM = 15,
SIGURG = 16,
SIGSTOP = 17,
SIGTSTP = 18,
SIGCONT = 19,
SIGCHLD = 20,
SIGTTIN = 21,
SIGTTOU = 22,
SIGIO = 23,
SIGXCPU = 24,
SIGXFSZ = 25,
SIGVTALRM = 26,
SIGPROF = 27,
SIGWINCH = 28,
SIGINFO = 29,
SIGUSR1 = 30,
SIGUSR2 = 31
}
/** Signals numbers. This is platform dependent.
*/
export const Signal: typeof MacOSSignal | typeof LinuxSignal;
export {};
// @url js/console.d.ts
type ConsoleOptions = Partial<{
showHidden: boolean;
depth: number;
colors: boolean;
indentLevel: number;
}>;
/**
* `inspect()` converts input into string that has the same format
* as printed by `console.log(...)`;
*/
export function inspect(value: unknown, options?: ConsoleOptions): string;
// @url js/build.d.ts
export type OperatingSystem = "mac" | "win" | "linux";
export type Arch = "x64" | "arm64";
/** Build related information */
interface BuildInfo {
/** The CPU architecture. */
arch: Arch;
/** The operating system. */
os: OperatingSystem;
}
export const build: BuildInfo;
// @url js/version.d.ts
interface Version {
deno: string;
v8: string;
typescript: string;
}
export const version: Version;
export {};
// @url js/diagnostics.d.ts
/** The log category for a diagnostic message */
export enum DiagnosticCategory {
Log = 0,
Debug = 1,
Info = 2,
Error = 3,
Warning = 4,
Suggestion = 5
}
export interface DiagnosticMessageChain {
message: string;
category: DiagnosticCategory;
code: number;
next?: DiagnosticMessageChain[];
}
export interface DiagnosticItem {
/** A string message summarizing the diagnostic. */
message: string;
/** An ordered array of further diagnostics. */
messageChain?: DiagnosticMessageChain;
/** Information related to the diagnostic. This is present when there is a
* suggestion or other additional diagnostic information */
relatedInformation?: DiagnosticItem[];
/** The text of the source line related to the diagnostic */
sourceLine?: string;
/** The line number that is related to the diagnostic */
lineNumber?: number;
/** The name of the script resource related to the diagnostic */
scriptResourceName?: string;
/** The start position related to the diagnostic */
startPosition?: number;
/** The end position related to the diagnostic */
endPosition?: number;
/** The category of the diagnostic */
category: DiagnosticCategory;
/** A number identifier */
code: number;
/** The the start column of the sourceLine related to the diagnostic */
startColumn?: number;
/** The end column of the sourceLine related to the diagnostic */
endColumn?: number;
}
export interface Diagnostic {
/** An array of diagnostic items. */
items: DiagnosticItem[];
}
// @url js/compiler_api.ts
/** A specific subset TypeScript compiler options that can be supported by
* the Deno TypeScript compiler. */
export interface CompilerOptions {
/** Allow JavaScript files to be compiled. Defaults to `true`. */
allowJs?: boolean;
/** Allow default imports from modules with no default export. This does not
* affect code emit, just typechecking. Defaults to `false`. */
allowSyntheticDefaultImports?: boolean;
/** Allow accessing UMD globals from modules. Defaults to `false`. */
allowUmdGlobalAccess?: boolean;
/** Do not report errors on unreachable code. Defaults to `false`. */
allowUnreachableCode?: boolean;
/** Do not report errors on unused labels. Defaults to `false` */
allowUnusedLabels?: boolean;
/** Parse in strict mode and emit `"use strict"` for each source file.
* Defaults to `true`. */
alwaysStrict?: boolean;
/** Base directory to resolve non-relative module names. Defaults to
* `undefined`. */
baseUrl?: string;
/** Report errors in `.js` files. Use in conjunction with `allowJs`. Defaults
* to `false`. */
checkJs?: boolean;
/** Generates corresponding `.d.ts` file. Defaults to `false`. */
declaration?: boolean;
/** Output directory for generated declaration files. */
declarationDir?: string;
/** Generates a source map for each corresponding `.d.ts` file. Defaults to
* `false`. */
declarationMap?: boolean;
/** Provide full support for iterables in `for..of`, spread and
* destructuring when targeting ES5 or ES3. Defaults to `false`. */
downlevelIteration?: boolean;
/** Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files.
* Defaults to `false`. */
emitBOM?: boolean;
/** Only emit `.d.ts` declaration files. Defaults to `false`. */
emitDeclarationOnly?: boolean;
/** Emit design-type metadata for decorated declarations in source. See issue
* [microsoft/TypeScript#2577](https://github.com/Microsoft/TypeScript/issues/2577)
* for details. Defaults to `false`. */
emitDecoratorMetadata?: boolean;
/** Emit `__importStar` and `__importDefault` helpers for runtime babel
* ecosystem compatibility and enable `allowSyntheticDefaultImports` for type
* system compatibility. Defaults to `true`. */
esModuleInterop?: boolean;
/** Enables experimental support for ES decorators. Defaults to `false`. */
experimentalDecorators?: boolean;
/** Emit a single file with source maps instead of having a separate file.
* Defaults to `false`. */
inlineSourceMap?: boolean;
/** Emit the source alongside the source maps within a single file; requires
* `inlineSourceMap` or `sourceMap` to be set. Defaults to `false`. */
inlineSources?: boolean;
/** Perform additional checks to ensure that transpile only would be safe.
* Defaults to `false`. */
isolatedModules?: boolean;
/** Support JSX in `.tsx` files: `"react"`, `"preserve"`, `"react-native"`.
* Defaults to `"react"`. */
jsx?: "react" | "preserve" | "react-native";
/** Specify the JSX factory function to use when targeting react JSX emit,
* e.g. `React.createElement` or `h`. Defaults to `React.createElement`. */
jsxFactory?: string;
/** Resolve keyof to string valued property names only (no numbers or
* symbols). Defaults to `false`. */
keyofStringsOnly?: string;
/** Emit class fields with ECMAScript-standard semantics. Defaults to `false`.
* Does not apply to `"esnext"` target. */
useDefineForClassFields?: boolean;
/** The locale to use to show error messages. */
locale?: string;
/** Specifies the location where debugger should locate map files instead of
* generated locations. Use this flag if the `.map` files will be located at
* run-time in a different location than the `.js` files. The location
* specified will be embedded in the source map to direct the debugger where
* the map files will be located. Defaults to `undefined`. */
mapRoot?: string;
/** Specify the module format for the emitted code. Defaults to
* `"esnext"`. */
module?:
| "none"
| "commonjs"
| "amd"
| "system"
| "umd"
| "es6"
| "es2015"
| "esnext";
/** Do not generate custom helper functions like `__extends` in compiled
* output. Defaults to `false`. */
noEmitHelpers?: boolean;
/** Report errors for fallthrough cases in switch statement. Defaults to
* `false`. */
noFallthroughCasesInSwitch?: boolean;
/** Raise error on expressions and declarations with an implied any type.
* Defaults to `true`. */
noImplicitAny?: boolean;
/** Report an error when not all code paths in function return a value.
* Defaults to `false`. */
noImplicitReturns?: boolean;
/** Raise error on `this` expressions with an implied `any` type. Defaults to
* `true`. */
noImplicitThis?: boolean;
/** Do not emit `"use strict"` directives in module output. Defaults to
* `false`. */
noImplicitUseStrict?: boolean;
/** Do not add triple-slash references or module import targets to the list of
* compiled files. Defaults to `false`. */
noResolve?: boolean;
/** Disable strict checking of generic signatures in function types. Defaults
* to `false`. */
noStrictGenericChecks?: boolean;
/** Report errors on unused locals. Defaults to `false`. */
noUnusedLocals?: boolean;
/** Report errors on unused parameters. Defaults to `false`. */
noUnusedParameters?: boolean;
/** Redirect output structure to the directory. This only impacts
* `Deno.compile` and only changes the emitted file names. Defaults to
* `undefined`. */
outDir?: string;
/** List of path mapping entries for module names to locations relative to the
* `baseUrl`. Defaults to `undefined`. */
paths?: Record;
/** Do not erase const enum declarations in generated code. Defaults to
* `false`. */
preserveConstEnums?: boolean;
/** Remove all comments except copy-right header comments beginning with
* `/*!`. Defaults to `true`. */
removeComments?: boolean;
/** Include modules imported with `.json` extension. Defaults to `true`. */
resolveJsonModule?: boolean;
/** Specifies the root directory of input files. Only use to control the
* output directory structure with `outDir`. Defaults to `undefined`. */
rootDir?: string;
/** List of _root_ folders whose combined content represent the structure of
* the project at runtime. Defaults to `undefined`. */
rootDirs?: string[];
/** Generates corresponding `.map` file. Defaults to `false`. */
sourceMap?: boolean;
/** Specifies the location where debugger should locate TypeScript files
* instead of source locations. Use this flag if the sources will be located
* at run-time in a different location than that at design-time. The location
* specified will be embedded in the sourceMap to direct the debugger where
* the source files will be located. Defaults to `undefined`. */
sourceRoot?: string;
/** Enable all strict type checking options. Enabling `strict` enables
* `noImplicitAny`, `noImplicitThis`, `alwaysStrict`, `strictBindCallApply`,
* `strictNullChecks`, `strictFunctionTypes` and
* `strictPropertyInitialization`. Defaults to `true`. */
strict?: boolean;
/** Enable stricter checking of the `bind`, `call`, and `apply` methods on
* functions. Defaults to `true`. */
strictBindCallApply?: boolean;
/** Disable bivariant parameter checking for function types. Defaults to
* `true`. */
strictFunctionTypes?: boolean;
/** Ensure non-undefined class properties are initialized in the constructor.
* This option requires `strictNullChecks` be enabled in order to take effect.
* Defaults to `true`. */
strictPropertyInitialization?: boolean;
/** In strict null checking mode, the `null` and `undefined` values are not in
* the domain of every type and are only assignable to themselves and `any`
* (the one exception being that `undefined` is also assignable to `void`). */
strictNullChecks?: boolean;
/** Suppress excess property checks for object literals. Defaults to
* `false`. */
suppressExcessPropertyErrors?: boolean;
/** Suppress `noImplicitAny` errors for indexing objects lacking index
* signatures. */
suppressImplicitAnyIndexErrors?: boolean;
/** Specify ECMAScript target version. Defaults to `esnext`. */
target?:
| "es3"
| "es5"
| "es6"
| "es2015"
| "es2016"
| "es2017"
| "es2018"
| "es2019"
| "es2020"
| "esnext";
/** List of names of type definitions to include. Defaults to `undefined`. */
types?: string[];
}
/** The results of a transpile only command, where the `source` contains the
* emitted source, and `map` optionally contains the source map.
*/
export interface TranspileOnlyResult {
source: string;
map?: string;
}
/** Takes a set of TypeScript sources and resolves with a map where the key was
* the original file name provided in sources and the result contains the
* `source` and optionally the `map` from the transpile operation. This does no
* type checking and validation, it effectively "strips" the types from the
* file.
*
* 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
* to transpile. The filename is only used in the transpile and
* not resolved, for example to fill in the source name in the
* source map.
* @param options An option object of options to send to the compiler. This is
* a subset of ts.CompilerOptions which can be supported by Deno.
* Many of the options related to type checking and emitting
* type declaration files will have no impact on the output.
*/
export function transpileOnly(
sources: Record,
options?: CompilerOptions
): Promise>;
/** Takes a root module name, any optionally a record set of sources. Resolves
* with a compiled set of modules. If just a root name is provided, the modules
* will be resolved as if the root module had been passed on the command line.
*
* If sources are passed, all modules will be resolved out of this object, where
* 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.
*
* const [ maybeDiagnostics1, output1 ] = await Deno.compile("foo.ts");
*
* const [ maybeDiagnostics2, output2 ] = await Deno.compile("/foo.ts", {
* "/foo.ts": `export * from "./bar.ts";`,
* "/bar.ts": `export const bar = "bar";`
* });
*
* @param rootName The root name of the module which will be used as the
* "starting point". If no `sources` is specified, Deno will
* resolve the module externally as if the `rootName` had been
* specified on the command line.
* @param sources An optional key/value map of sources to be used when resolving
* modules, where the key is the module name, and the value is
* the source content. The extension of the key will determine
* the media type of the file when processing. If supplied,
* Deno will not attempt to resolve any modules externally.
* @param options An optional object of options to send to the compiler. This is
* a subset of ts.CompilerOptions which can be supported by Deno.
*/
export function compile(
rootName: string,
sources?: Record,
options?: CompilerOptions
): Promise<[Diagnostic[] | undefined, Record]>;
/** Takes a root module name, and optionally a record set of sources. Resolves
* with a single JavaScript string that is like the output of a `deno bundle`
* command. If just a root name is provided, the modules will be resolved as if
* the root module had been passed on the command line.
*
* If sources are passed, all modules will be resolved out of this object, where
* 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.
*
* const [ maybeDiagnostics1, output1 ] = await Deno.bundle("foo.ts");
*
* const [ maybeDiagnostics2, output2 ] = await Deno.bundle("/foo.ts", {
* "/foo.ts": `export * from "./bar.ts";`,
* "/bar.ts": `export const bar = "bar";`
* });
*
* @param rootName The root name of the module which will be used as the
* "starting point". If no `sources` is specified, Deno will
* resolve the module externally as if the `rootName` had been
* specified on the command line.
* @param sources An optional key/value map of sources to be used when resolving
* modules, where the key is the module name, and the value is
* the source content. The extension of the key will determine
* the media type of the file when processing. If supplied,
* Deno will not attempt to resolve any modules externally.
* @param options An optional object of options to send to the compiler. This is
* a subset of ts.CompilerOptions which can be supported by Deno.
*/
export function bundle(
rootName: string,
sources?: Record,
options?: CompilerOptions
): Promise<[Diagnostic[] | undefined, string]>;
// @url js/deno.d.ts
export const args: string[];
/** Special Deno related symbols. */
export const symbols: {
/** Symbol to access exposed internal Deno API */
readonly internal: unique symbol;
/** A symbol which can be used as a key for a custom method which will be called
* when `Deno.inspect()` is called, or when the object is logged to the console.
*/
readonly customInspect: unique symbol;
};
}
// @url js/globals.ts
declare interface Window {
window: Window & typeof globalThis;
atob: typeof __textEncoding.atob;
btoa: typeof __textEncoding.btoa;
fetch: typeof __fetch.fetch;
clearTimeout: typeof __timers.clearTimeout;
clearInterval: typeof __timers.clearInterval;
console: __console.Console;
setTimeout: typeof __timers.setTimeout;
setInterval: typeof __timers.setInterval;
location: __domTypes.Location;
onload: Function | undefined;
onunload: Function | undefined;
crypto: Crypto;
Blob: typeof __blob.DenoBlob;
File: __domTypes.DomFileConstructor;
CustomEvent: typeof __customEvent.CustomEvent;
Event: typeof __event.Event;
EventTarget: typeof __eventTarget.EventTarget;
URL: typeof __url.URL;
URLSearchParams: typeof __urlSearchParams.URLSearchParams;
Headers: __domTypes.HeadersConstructor;
FormData: __domTypes.FormDataConstructor;
TextEncoder: typeof __textEncoding.TextEncoder;
TextDecoder: typeof __textEncoding.TextDecoder;
Request: __domTypes.RequestConstructor;
Response: typeof __fetch.Response;
performance: __performanceUtil.Performance;
onmessage: (e: { data: any }) => void;
workerMain: typeof __workers.workerMain;
workerClose: typeof __workers.workerClose;
postMessage: typeof __workers.postMessage;
Worker: typeof __workers.WorkerImpl;
addEventListener: (
type: string,
callback: (event: __domTypes.Event) => void | null,
options?: boolean | __domTypes.AddEventListenerOptions | undefined
) => void;
dispatchEvent: (event: __domTypes.Event) => boolean;
removeEventListener: (
type: string,
callback: (event: __domTypes.Event) => void | null,
options?: boolean | __domTypes.EventListenerOptions | undefined
) => void;
queueMicrotask: (task: () => void) => void;
Deno: typeof Deno;
}
declare const window: Window & typeof globalThis;
declare const atob: typeof __textEncoding.atob;
declare const btoa: typeof __textEncoding.btoa;
declare const fetch: typeof __fetch.fetch;
declare const clearTimeout: typeof __timers.clearTimeout;
declare const clearInterval: typeof __timers.clearInterval;
declare const console: __console.Console;
declare const setTimeout: typeof __timers.setTimeout;
declare const setInterval: typeof __timers.setInterval;
declare const location: __domTypes.Location;
declare const onload: Function | undefined;
declare const onunload: Function | undefined;
declare const crypto: Crypto;
declare const Blob: typeof __blob.DenoBlob;
declare const File: __domTypes.DomFileConstructor;
declare const CustomEventInit: typeof __customEvent.CustomEventInit;
declare const CustomEvent: typeof __customEvent.CustomEvent;
declare const EventInit: typeof __event.EventInit;
declare const Event: typeof __event.Event;
declare const EventListener: typeof __eventTarget.EventListener;
declare const EventTarget: typeof __eventTarget.EventTarget;
declare const URL: typeof __url.URL;
declare const URLSearchParams: typeof __urlSearchParams.URLSearchParams;
declare const Headers: __domTypes.HeadersConstructor;
declare const FormData: __domTypes.FormDataConstructor;
declare const TextEncoder: typeof __textEncoding.TextEncoder;
declare const TextDecoder: typeof __textEncoding.TextDecoder;
declare const Request: __domTypes.RequestConstructor;
declare const Response: typeof __fetch.Response;
declare const performance: __performanceUtil.Performance;
declare let onmessage: (e: { data: any }) => void;
declare const workerMain: typeof __workers.workerMain;
declare const workerClose: typeof __workers.workerClose;
declare const postMessage: typeof __workers.postMessage;
declare const Worker: typeof __workers.WorkerImpl;
declare const addEventListener: (
type: string,
callback: (event: __domTypes.Event) => void | null,
options?: boolean | __domTypes.AddEventListenerOptions | undefined
) => void;
declare const dispatchEvent: (event: __domTypes.Event) => boolean;
declare const removeEventListener: (
type: string,
callback: (event: __domTypes.Event) => void | null,
options?: boolean | __domTypes.EventListenerOptions | undefined
) => void;
declare type Blob = __domTypes.Blob;
declare type Body = __domTypes.Body;
declare type File = __domTypes.DomFile;
declare type CustomEventInit = __domTypes.CustomEventInit;
declare type CustomEvent = __domTypes.CustomEvent;
declare type EventInit = __domTypes.EventInit;
declare type Event = __domTypes.Event;
declare type EventListener = __domTypes.EventListener;
declare type EventTarget = __domTypes.EventTarget;
declare type URL = __url.URL;
declare type URLSearchParams = __domTypes.URLSearchParams;
declare type Headers = __domTypes.Headers;
declare type FormData = __domTypes.FormData;
declare type TextEncoder = __textEncoding.TextEncoder;
declare type TextDecoder = __textEncoding.TextDecoder;
declare type Request = __domTypes.Request;
declare type Response = __domTypes.Response;
declare type Worker = __workers.Worker;
declare interface ImportMeta {
url: string;
main: boolean;
}
declare interface Crypto {
readonly subtle: null;
getRandomValues: <
T extends
| Int8Array
| Uint8Array
| Uint8ClampedArray
| Int16Array
| Uint16Array
| Int32Array
| Uint32Array
>(
typedArray: T
) => T;
}
declare namespace __domTypes {
// @url js/dom_types.d.ts
export type BufferSource = ArrayBufferView | ArrayBuffer;
export type HeadersInit =
| Headers
| Array<[string, string]>
| Record;
export type URLSearchParamsInit =
| string
| string[][]
| Record;
type BodyInit =
| Blob
| BufferSource
| FormData
| URLSearchParams
| ReadableStream
| string;
export type RequestInfo = Request | string;
type ReferrerPolicy =
| ""
| "no-referrer"
| "no-referrer-when-downgrade"
| "origin-only"
| "origin-when-cross-origin"
| "unsafe-url";
export type BlobPart = BufferSource | Blob | string;
export type FormDataEntryValue = DomFile | string;
export interface DomIterable {
keys(): IterableIterator;
values(): IterableIterator;
entries(): IterableIterator<[K, V]>;
[Symbol.iterator](): IterableIterator<[K, V]>;
forEach(
callback: (value: V, key: K, parent: this) => void,
thisArg?: any
): void;
}
type EndingType = "transparent" | "native";
export interface BlobPropertyBag {
type?: string;
ending?: EndingType;
}
interface AbortSignalEventMap {
abort: ProgressEvent;
}
export enum NodeType {
ELEMENT_NODE = 1,
TEXT_NODE = 3,
DOCUMENT_FRAGMENT_NODE = 11
}
export const eventTargetHost: unique symbol;
export const eventTargetListeners: unique symbol;
export const eventTargetMode: unique symbol;
export const eventTargetNodeType: unique symbol;
export interface EventTarget {
[eventTargetHost]: EventTarget | null;
[eventTargetListeners]: { [type in string]: EventListener[] };
[eventTargetMode]: string;
[eventTargetNodeType]: NodeType;
addEventListener(
type: string,
callback: (event: Event) => void | null,
options?: boolean | AddEventListenerOptions
): void;
dispatchEvent(event: Event): boolean;
removeEventListener(
type: string,
callback?: (event: Event) => void | null,
options?: EventListenerOptions | boolean
): void;
}
export interface ProgressEventInit extends EventInit {
lengthComputable?: boolean;
loaded?: number;
total?: number;
}
export interface URLSearchParams extends DomIterable {
/**
* Appends a specified key/value pair as a new search parameter.
*/
append(name: string, value: string): void;
/**
* Deletes the given search parameter, and its associated value,
* from the list of all search parameters.
*/
delete(name: string): void;
/**
* Returns the first value associated to the given search parameter.
*/
get(name: string): string | null;
/**
* Returns all the values association with a given search parameter.
*/
getAll(name: string): string[];
/**
* Returns a Boolean indicating if such a search parameter exists.
*/
has(name: string): boolean;
/**
* Sets the value associated to a given search parameter to the given value.
* If there were several values, delete the others.
*/
set(name: string, value: string): void;
/**
* Sort all key/value pairs contained in this object in place
* and return undefined. The sort order is according to Unicode
* code points of the keys.
*/
sort(): void;
/**
* Returns a query string suitable for use in a URL.
*/
toString(): string;
/**
* Iterates over each name-value pair in the query
* and invokes the given function.
*/
forEach(
callbackfn: (value: string, key: string, parent: this) => void,
thisArg?: any
): void;
}
export interface EventListener {
handleEvent(event: Event): void;
readonly callback: (event: Event) => void | null;
readonly options: boolean | AddEventListenerOptions;
}
export interface EventInit {
bubbles?: boolean;
cancelable?: boolean;
composed?: boolean;
}
export interface CustomEventInit extends EventInit {
detail?: any;
}
export enum EventPhase {
NONE = 0,
CAPTURING_PHASE = 1,
AT_TARGET = 2,
BUBBLING_PHASE = 3
}
export interface EventPath {
item: EventTarget;
itemInShadowTree: boolean;
relatedTarget: EventTarget | null;
rootOfClosedTree: boolean;
slotInClosedTree: boolean;
target: EventTarget | null;
touchTargetList: EventTarget[];
}
export interface Event {
readonly type: string;
target: EventTarget | null;
currentTarget: EventTarget | null;
composedPath(): EventPath[];
eventPhase: number;
stopPropagation(): void;
stopImmediatePropagation(): void;
readonly bubbles: boolean;
readonly cancelable: boolean;
preventDefault(): void;
readonly defaultPrevented: boolean;
readonly composed: boolean;
isTrusted: boolean;
readonly timeStamp: Date;
dispatched: boolean;
readonly initialized: boolean;
inPassiveListener: boolean;
cancelBubble: boolean;
cancelBubbleImmediately: boolean;
path: EventPath[];
relatedTarget: EventTarget | null;
}
export interface CustomEvent extends Event {
readonly detail: any;
initCustomEvent(
type: string,
bubbles?: boolean,
cancelable?: boolean,
detail?: any | null
): void;
}
export interface DomFile extends Blob {
readonly lastModified: number;
readonly name: string;
}
export interface DomFileConstructor {
new (
bits: BlobPart[],
filename: string,
options?: FilePropertyBag
): DomFile;
prototype: DomFile;
}
export interface FilePropertyBag extends BlobPropertyBag {
lastModified?: number;
}
interface ProgressEvent extends Event {
readonly lengthComputable: boolean;
readonly loaded: number;
readonly total: number;
}
export interface EventListenerOptions {
capture: boolean;
}
export interface AddEventListenerOptions extends EventListenerOptions {
once: boolean;
passive: boolean;
}
interface AbortSignal extends EventTarget {
readonly aborted: boolean;
onabort: ((this: AbortSignal, ev: ProgressEvent) => any) | null;
addEventListener(
type: K,
listener: (this: AbortSignal, ev: AbortSignalEventMap[K]) => any,
options?: boolean | AddEventListenerOptions
): void;
addEventListener(
type: string,
listener: EventListener,
options?: boolean | AddEventListenerOptions
): void;
removeEventListener(
type: K,
listener: (this: AbortSignal, ev: AbortSignalEventMap[K]) => any,
options?: boolean | EventListenerOptions
): void;
removeEventListener(
type: string,
listener: EventListener,
options?: boolean | EventListenerOptions
): void;
}
export interface ReadableStream {
readonly locked: boolean;
cancel(): Promise;
getReader(): ReadableStreamReader;
tee(): [ReadableStream, ReadableStream];
}
export interface ReadableStreamReader {
cancel(): Promise;
read(): Promise;
releaseLock(): void;
}
export interface FormData extends DomIterable {
append(name: string, value: string | Blob, fileName?: string): void;
delete(name: string): void;
get(name: string): FormDataEntryValue | null;
getAll(name: string): FormDataEntryValue[];
has(name: string): boolean;
set(name: string, value: string | Blob, fileName?: string): void;
}
export interface FormDataConstructor {
new (): FormData;
prototype: FormData;
}
/** A blob object represents a file-like object of immutable, raw data. */
export interface Blob {
/** The size, in bytes, of the data contained in the `Blob` object. */
readonly size: number;
/** A string indicating the media type of the data contained in the `Blob`.
* If the type is unknown, this string is empty.
*/
readonly type: string;
/** Returns a new `Blob` object containing the data in the specified range of
* bytes of the source `Blob`.
*/
slice(start?: number, end?: number, contentType?: string): Blob;
}
export interface Body {
/** A simple getter used to expose a `ReadableStream` of the body contents. */
readonly body: ReadableStream | null;
/** Stores a `Boolean` that declares whether the body has been used in a
* response yet.
*/
readonly bodyUsed: boolean;
/** Takes a `Response` stream and reads it to completion. It returns a promise
* that resolves with an `ArrayBuffer`.
*/
arrayBuffer(): Promise;
/** Takes a `Response` stream and reads it to completion. It returns a promise
* that resolves with a `Blob`.
*/
blob(): Promise;
/** Takes a `Response` stream and reads it to completion. It returns a promise
* that resolves with a `FormData` object.
*/
formData(): Promise;
/** Takes a `Response` stream and reads it to completion. It returns a promise
* that resolves with the result of parsing the body text as JSON.
*/
json(): Promise;
/** Takes a `Response` stream and reads it to completion. It returns a promise
* that resolves with a `USVString` (text).
*/
text(): Promise;
}
export interface Headers extends DomIterable {
/** Appends a new value onto an existing header inside a `Headers` object, or
* adds the header if it does not already exist.
*/
append(name: string, value: string): void;
/** Deletes a header from a `Headers` object. */
delete(name: string): void;
/** Returns an iterator allowing to go through all key/value pairs
* contained in this Headers object. The both the key and value of each pairs
* are ByteString objects.
*/
entries(): IterableIterator<[string, string]>;
/** Returns a `ByteString` sequence of all the values of a header within a
* `Headers` object with a given name.
*/
get(name: string): string | null;
/** Returns a boolean stating whether a `Headers` object contains a certain
* header.
*/
has(name: string): boolean;
/** Returns an iterator allowing to go through all keys contained in
* this Headers object. The keys are ByteString objects.
*/
keys(): IterableIterator;
/** Sets a new value for an existing header inside a Headers object, or adds
* the header if it does not already exist.
*/
set(name: string, value: string): void;
/** Returns an iterator allowing to go through all values contained in
* this Headers object. The values are ByteString objects.
*/
values(): IterableIterator;
forEach(
callbackfn: (value: string, key: string, parent: this) => void,
thisArg?: any
): void;
/** The Symbol.iterator well-known symbol specifies the default
* iterator for this Headers object
*/
[Symbol.iterator](): IterableIterator<[string, string]>;
}
export interface HeadersConstructor {
new (init?: HeadersInit): Headers;
prototype: Headers;
}
type RequestCache =
| "default"
| "no-store"
| "reload"
| "no-cache"
| "force-cache"
| "only-if-cached";
type RequestCredentials = "omit" | "same-origin" | "include";
type RequestDestination =
| ""
| "audio"
| "audioworklet"
| "document"
| "embed"
| "font"
| "image"
| "manifest"
| "object"
| "paintworklet"
| "report"
| "script"
| "sharedworker"
| "style"
| "track"
| "video"
| "worker"
| "xslt";
type RequestMode = "navigate" | "same-origin" | "no-cors" | "cors";
type RequestRedirect = "follow" | "error" | "manual";
type ResponseType =
| "basic"
| "cors"
| "default"
| "error"
| "opaque"
| "opaqueredirect";
export interface RequestInit {
body?: BodyInit | null;
cache?: RequestCache;
credentials?: RequestCredentials;
headers?: HeadersInit;
integrity?: string;
keepalive?: boolean;
method?: string;
mode?: RequestMode;
redirect?: RequestRedirect;
referrer?: string;
referrerPolicy?: ReferrerPolicy;
signal?: AbortSignal | null;
window?: any;
}
export interface ResponseInit {
headers?: HeadersInit;
status?: number;
statusText?: string;
}
export interface RequestConstructor {
new (input: RequestInfo, init?: RequestInit): Request;
prototype: Request;
}
export interface Request extends Body {
/** Returns the cache mode associated with request, which is a string
* indicating how the the request will interact with the browser's cache when
* fetching.
*/
readonly cache?: RequestCache;
/** Returns the credentials mode associated with request, which is a string
* indicating whether credentials will be sent with the request always, never,
* or only when sent to a same-origin URL.
*/
readonly credentials?: RequestCredentials;
/** Returns the kind of resource requested by request, (e.g., `document` or
* `script`).
*/
readonly destination?: RequestDestination;
/** Returns a Headers object consisting of the headers associated with
* request.
*
* Note that headers added in the network layer by the user agent
* will not be accounted for in this object, (e.g., the `Host` header).
*/
readonly headers: Headers;
/** Returns request's subresource integrity metadata, which is a cryptographic
* hash of the resource being fetched. Its value consists of multiple hashes
* separated by whitespace. [SRI]
*/
readonly integrity?: string;
/** Returns a boolean indicating whether or not request is for a history
* navigation (a.k.a. back-forward navigation).
*/
readonly isHistoryNavigation?: boolean;
/** Returns a boolean indicating whether or not request is for a reload
* navigation.
*/
readonly isReloadNavigation?: boolean;
/** Returns a boolean indicating whether or not request can outlive the global
* in which it was created.
*/
readonly keepalive?: boolean;
/** Returns request's HTTP method, which is `GET` by default. */
readonly method: string;
/** Returns the mode associated with request, which is a string indicating
* whether the request will use CORS, or will be restricted to same-origin
* URLs.
*/
readonly mode?: RequestMode;
/** Returns the redirect mode associated with request, which is a string
* indicating how redirects for the request will be handled during fetching.
*
* A request will follow redirects by default.
*/
readonly redirect?: RequestRedirect;
/** Returns the referrer of request. Its value can be a same-origin URL if
* explicitly set in init, the empty string to indicate no referrer, and
* `about:client` when defaulting to the global's default.
*
* This is used during fetching to determine the value of the `Referer`
* header of the request being made.
*/
readonly referrer?: string;
/** Returns the referrer policy associated with request. This is used during
* fetching to compute the value of the request's referrer.
*/
readonly referrerPolicy?: ReferrerPolicy;
/** Returns the signal associated with request, which is an AbortSignal object
* indicating whether or not request has been aborted, and its abort event
* handler.
*/
readonly signal?: AbortSignal;
/** Returns the URL of request as a string. */
readonly url: string;
clone(): Request;
}
export interface Response extends Body {
/** Contains the `Headers` object associated with the response. */
readonly headers: Headers;
/** Contains a boolean stating whether the response was successful (status in
* the range 200-299) or not.
*/
readonly ok: boolean;
/** Indicates whether or not the response is the result of a redirect; that
* is, its URL list has more than one entry.
*/
readonly redirected: boolean;
/** Contains the status code of the response (e.g., `200` for a success). */
readonly status: number;
/** Contains the status message corresponding to the status code (e.g., `OK`
* for `200`).
*/
readonly statusText: string;
readonly trailer: Promise;
/** Contains the type of the response (e.g., `basic`, `cors`). */
readonly type: ResponseType;
/** Contains the URL of the response. */
readonly url: string;
/** Creates a clone of a `Response` object. */
clone(): Response;
}
export interface Location {
/**
* Returns a DOMStringList object listing the origins of the ancestor browsing
* contexts, from the parent browsing context to the top-level browsing
* context.
*/
readonly ancestorOrigins: string[];
/**
* Returns the Location object's URL's fragment (includes leading "#" if
* non-empty).
* Can be set, to navigate to the same URL with a changed fragment (ignores
* leading "#").
*/
hash: string;
/**
* Returns the Location object's URL's host and port (if different from the
* default port for the scheme). Can be set, to navigate to the same URL with
* a changed host and port.
*/
host: string;
/**
* Returns the Location object's URL's host. Can be set, to navigate to the
* same URL with a changed host.
*/
hostname: string;
/**
* Returns the Location object's URL. Can be set, to navigate to the given
* URL.
*/
href: string;
/** Returns the Location object's URL's origin. */
readonly origin: string;
/**
* Returns the Location object's URL's path.
* Can be set, to navigate to the same URL with a changed path.
*/
pathname: string;
/**
* Returns the Location object's URL's port.
* Can be set, to navigate to the same URL with a changed port.
*/
port: string;
/**
* Returns the Location object's URL's scheme.
* Can be set, to navigate to the same URL with a changed scheme.
*/
protocol: string;
/**
* Returns the Location object's URL's query (includes leading "?" if
* non-empty). Can be set, to navigate to the same URL with a changed query
* (ignores leading "?").
*/
search: string;
/**
* Navigates to the given URL.
*/
assign(url: string): void;
/**
* Reloads the current page.
*/
reload(): void;
/** @deprecated */
reload(forcedReload: boolean): void;
/**
* Removes the current page from the session history and navigates to the
* given URL.
*/
replace(url: string): void;
}
}
declare namespace __blob {
// @url js/blob.d.ts
export const bytesSymbol: unique symbol;
export const blobBytesWeakMap: WeakMap<__domTypes.Blob, Uint8Array>;
export class DenoBlob implements __domTypes.Blob {
private readonly [bytesSymbol];
readonly size: number;
readonly type: string;
/** A blob object represents a file-like object of immutable, raw data. */
constructor(
blobParts?: __domTypes.BlobPart[],
options?: __domTypes.BlobPropertyBag
);
slice(start?: number, end?: number, contentType?: string): DenoBlob;
}
}
declare namespace __console {
// @url js/console.d.ts
type ConsoleOptions = Partial<{
showHidden: boolean;
depth: number;
colors: boolean;
indentLevel: number;
}>;
export class CSI {
static kClear: string;
static kClearScreenDown: string;
}
const isConsoleInstance: unique symbol;
export class Console {
private printFunc;
indentLevel: number;
[isConsoleInstance]: boolean;
/** Writes the arguments to stdout */
log: (...args: unknown[]) => void;
/** Writes the arguments to stdout */
debug: (...args: unknown[]) => void;
/** Writes the arguments to stdout */
info: (...args: unknown[]) => void;
/** Writes the properties of the supplied `obj` to stdout */
dir: (
obj: unknown,
options?: Partial<{
showHidden: boolean;
depth: number;
colors: boolean;
indentLevel: number;
}>
) => void;
/** From MDN:
* Displays an interactive tree of the descendant elements of
* the specified XML/HTML element. If it is not possible to display
* as an element the JavaScript Object view is shown instead.
* The output is presented as a hierarchical listing of expandable
* nodes that let you see the contents of child nodes.
*
* Since we write to stdout, we can't display anything interactive
* we just fall back to `console.dir`.
*/
dirxml: (
obj: unknown,
options?: Partial<{
showHidden: boolean;
depth: number;
colors: boolean;
indentLevel: number;
}>
) => void;
/** Writes the arguments to stdout */
warn: (...args: unknown[]) => void;
/** Writes the arguments to stdout */
error: (...args: unknown[]) => void;
/** Writes an error message to stdout if the assertion is `false`. If the
* assertion is `true`, nothing happens.
*
* ref: https://console.spec.whatwg.org/#assert
*/
assert: (condition?: boolean, ...args: unknown[]) => void;
count: (label?: string) => void;
countReset: (label?: string) => void;
table: (data: unknown, properties?: string[] | undefined) => void;
time: (label?: string) => void;
timeLog: (label?: string, ...args: unknown[]) => void;
timeEnd: (label?: string) => void;
group: (...label: unknown[]) => void;
groupCollapsed: (...label: unknown[]) => void;
groupEnd: () => void;
clear: () => void;
trace: (...args: unknown[]) => void;
static [Symbol.hasInstance](instance: Console): boolean;
}
/** A symbol which can be used as a key for a custom method which will be called
* when `Deno.inspect()` is called, or when the object is logged to the console.
*/
export const customInspect: unique symbol;
/**
* `inspect()` converts input into string that has the same format
* as printed by `console.log(...)`;
*/
export function inspect(value: unknown, options?: ConsoleOptions): string;
}
declare namespace __event {
// @url js/event.d.ts
export const eventAttributes: WeakMap