Skip to main content
Module

x/oak/lib/lib.deno_runtime.d.ts

A middleware framework for handling HTTP with Deno 🐿️ 🦕
Extremely Popular
Go to Latest
File
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373
// Copyright 2018 the Deno authors. All rights reserved. MIT license.
/// <reference no-default-lib="true" />/// <reference lib="esnext" />
// @url js/globals.ts
declare module "deno" { // @url js/os.d.ts
/** Exit the Deno process with optional exit code. */ export function exit(exitCode?: 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 or `number`s * as values. * * import { env } from "deno"; * * const myEnv = env(); * console.log(myEnv.SHELL); * myEnv.TEST_VAR = "HELLO"; * const newEnv = env(); * console.log(myEnv.TEST_VAR == newEnv.TEST_VAR); */ export function env(): { [index: string]: 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 interface ReadResult { nread: number; eof: boolean; } export interface Reader { /** Reads up to p.byteLength bytes into `p`. It resolves to the number * of bytes read (`0` <= `n` <= `p.byteLength`) and 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 an error or end-of-file condition after * successfully reading `n` > `0` bytes, it returns the number of bytes read. * It may return the (non-nil) error from the same call or return the error * (and `n` == `0`) from a subsequent call. An instance of this general case * is that a `Reader` returning a non-zero number of bytes at the end of the * input stream may return either `err` == `EOF` or `err` == `null`. The next * `read()` should return `0`, `EOF`. * * 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 of `read()` are discouraged from returning a zero byte * count with a `null` error, except when `p.byteLength` == `0`. Callers * should treat a return of `0` and `null` as indicating that nothing * happened; in particular it does not indicate `EOF`. * * Implementations must not retain `p`. */ read(p: Uint8Array): Promise<ReadResult>; } 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<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: number): Promise<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<number>; /** Turns `r` into async iterator. * * for await (const chunk of readerIterator(reader)) { * console.log(chunk) * } */ export function toAsyncIterator(r: Reader): AsyncIterableIterator<Uint8Array>;
// @url js/files.d.ts
/** The Deno abstraction for reading and writing files. */ export class File implements Reader, Writer, Closer { readonly rid: number; constructor(rid: number); write(p: Uint8Array): Promise<number>; read(p: Uint8Array): Promise<ReadResult>; 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+"; /** A factory function for creating instances of `File` associated with the * supplied file name. */ function create(filename: string): Promise<File>; /** Open a file and return an instance of the `File` object. * * import * as deno from "deno"; * (async () => { * const file = await deno.open("/foo/bar.txt"); * })(); */ export function open(filename: string, mode?: OpenMode): Promise<File>; /** Read from a file ID into an array buffer. * * Resolves with the `ReadResult` for the operation. */ export function read(rid: number, p: Uint8Array): Promise<ReadResult>; /** Write to the file ID the contents of the array buffer. * * Resolves with the number of bytes written. */ export function write(rid: number, p: Uint8Array): Promise<number>; /** Close the file ID. */ export function close(rid: number): void;
// @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, Writer { 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; /** read() 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. */ read(p: Uint8Array): Promise<ReadResult>; write(p: Uint8Array): Promise<number>; /** _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<number>; } /** Read `r` until EOF and return the content as `Uint8Array`. */ export function readAll(r: Reader): Promise<Uint8Array>;
// @url js/mkdir.d.ts
/** Creates a new directory with the specified path and permission * synchronously. * * import { mkdirSync } from "deno"; * mkdirSync("new_dir"); */ export function mkdirSync(path: string, mode?: number): void; /** Creates a new directory with the specified path and permission. * * import { mkdir } from "deno"; * await mkdir("new_dir"); */ export function mkdir(path: string, mode?: number): Promise<void>;
// @url js/make_temp_dir.d.ts
interface MakeTempDirOptions { dir?: string; prefix?: string; suffix?: string; } /** makeTempDirSync is the synchronous version of `makeTempDir`. * * import { makeTempDirSync } from "deno"; * const tempDirName0 = makeTempDirSync(); * const tempDirName1 = 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. * * import { makeTempDir } from "deno"; * const tempDirName0 = await makeTempDir(); * const tempDirName1 = await makeTempDir({ prefix: 'my_temp' }); */ export function makeTempDir(options?: MakeTempDirOptions): Promise<string>;
// @url js/chmod.d.ts
/** Changes the permission of a specific file/directory of specified path * synchronously. * * import { chmodSync } from "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. * * import { chmod } from "deno"; * await chmod("/path/to/file", 0o666); */ export function chmod(path: string, mode: number): Promise<void>;
// @url js/remove.d.ts
/** Removes the named file or (empty) directory synchronously. Would throw * error if permission denied, not found, or directory not empty. * * import { removeSync } from "deno"; * removeSync("/path/to/empty_dir/or/file"); */ export function removeSync(path: string): void; /** Removes the named file or (empty) directory. Would throw error if * permission denied, not found, or directory not empty. * * import { remove } from "deno"; * await remove("/path/to/empty_dir/or/file"); */ export function remove(path: string): Promise<void>; /** Recursively removes the named file or directory synchronously. Would throw * error if permission denied or not found. * * import { removeAllSync } from "deno"; * removeAllSync("/path/to/dir/or/file"); */ export function removeAllSync(path: string): void; /** Recursively removes the named file or directory. Would throw error if * permission denied or not found. * * import { removeAll } from "deno"; * await removeAll("/path/to/dir/or/file"); */ export function removeAll(path: string): Promise<void>;
// @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. * * import { renameSync } from "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. * * import { rename } from "deno"; * await rename("old/path", "new/path"); */ export function rename(oldpath: string, newpath: string): Promise<void>;
// @url js/read_file.d.ts
/** Read the entire contents of a file synchronously. * * import { readFileSync } from "deno"; * const decoder = new TextDecoder("utf-8"); * const data = readFileSync("hello.txt"); * console.log(decoder.decode(data)); */ export function readFileSync(filename: string): Uint8Array; /** Read the entire contents of a file. * * import { readFile } from "deno"; * const decoder = new TextDecoder("utf-8"); * const data = await readFile("hello.txt"); * console.log(decoder.decode(data)); */ export function readFile(filename: string): Promise<Uint8Array>;
// @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 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; /** Returns the file or directory name. */ name: string | null; /** Returns the file or directory path. */ path: string | 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/read_dir.d.ts
/** Reads the directory given by path and returns a list of file info * synchronously. * * import { readDirSync } from "deno"; * const files = readDirSync("/"); */ export function readDirSync(path: string): FileInfo[]; /** Reads the directory given by path and returns a list of file info. * * import { readDir } from "deno"; * const files = await readDir("/"); */ export function readDir(path: string): Promise<FileInfo[]>;
// @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. * * import { copyFileSync } from "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. * * import { copyFile } from "deno"; * await copyFile("from.txt", "to.txt"); */ export function copyFile(from: string, to: string): Promise<void>;
// @url js/read_link.d.ts
/** Returns the destination of the named symbolic link synchronously. * * import { readlinkSync } from "deno"; * const targetPath = readlinkSync("symlink/path"); */ export function readlinkSync(name: string): string; /** Returns the destination of the named symbolic link. * * import { readlink } from "deno"; * const targetPath = await readlink("symlink/path"); */ export function readlink(name: string): Promise<string>;
// @url js/stat.d.ts
/** Queries the file system for information on the path provided. If the given * path is a symlink information about the symlink will be returned. * * import { lstat } from "deno"; * const fileInfo = await lstat("hello.txt"); * assert(fileInfo.isFile()); */ export function lstat(filename: string): Promise<FileInfo>; /** 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. * * import { lstatSync } from "deno"; * const fileInfo = 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. * * import { stat } from "deno"; * const fileInfo = await stat("hello.txt"); * assert(fileInfo.isFile()); */ export function stat(filename: string): Promise<FileInfo>; /** Queries the file system for information on the path provided synchronously. * `statSync` Will always follow symlinks. * * import { statSync } from "deno"; * const fileInfo = statSync("hello.txt"); * assert(fileInfo.isFile()); */ export function statSync(filename: string): FileInfo;
// @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). * * import { symlinkSync } from "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). * * import { symlink } from "deno"; * await symlink("old/name", "new/name"); */ export function symlink( oldname: string, newname: string, type?: string ): Promise<void>;
// @url js/write_file.d.ts
/** Write a new file, with given filename and data synchronously. * * import { writeFileSync } from "deno"; * * const encoder = new TextEncoder("utf-8"); * const data = encoder.encode("Hello world\n"); * writeFileSync("hello.txt", data); */ export function writeFileSync( filename: string, data: Uint8Array, perm?: number ): void; /** Write a new file, with given filename and data. * * import { writeFile } from "deno"; * * const encoder = new TextEncoder("utf-8"); * const data = encoder.encode("Hello world\n"); * await writeFile("hello.txt", data); */ export function writeFile( filename: string, data: Uint8Array, perm?: number ): Promise<void>;
// @url target/debug/gen/msg_generated.ts
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 }
// @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. * * import { DenoError, ErrorKind } from "deno"; * try { * somethingThatMightThrow(); * } catch (e) { * if (e instanceof DenoError && e.kind === ErrorKind.Overflow) { * console.error("Overflow error!"); * } * } */ export class DenoError<T extends ErrorKind> extends Error { readonly kind: T; constructor(kind: T, msg: string); }
// @url js/libdeno.d.ts
type MessageCallback = (msg: Uint8Array) => void; type PromiseRejectEvent = | "RejectWithNoHandler" | "HandlerAddedAfterReject" | "ResolveAfterResolved" | "RejectAfterResolved"; interface Libdeno { recv(cb: MessageCallback): void; send(control: ArrayBufferView, data?: ArrayBufferView): null | Uint8Array; print(x: string, isErr?: boolean): void; shared: ArrayBuffer; setGlobalErrorHandler: ( handler: ( message: string, source: string, line: number, col: number, error: Error ) => void ) => void; setPromiseRejectHandler: ( handler: ( error: Error | string, event: PromiseRejectEvent, promise: Promise<any> ) => void ) => void; setPromiseErrorExaminer: (handler: () => boolean) => void; } export const libdeno: Libdeno; export {};
// @url js/platform.d.ts
interface Platform { /** The operating system CPU architecture. */ arch: "x64"; /** The operating system platform. */ os: "mac" | "win" | "linux"; } export const platform: Platform;
// @url js/truncate.d.ts
/** Truncates or extends the specified file synchronously, updating the size of * this file to become size. * * import { truncateSync } from "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. * * import { truncate } from "deno"; * * await truncate("hello.txt", 10); */ export function truncate(name: string, len?: number): Promise<void>;
// @url js/net.d.ts
type Network = "tcp"; type Addr = string; /** A Listener is a generic network listener for stream-oriented protocols. */ export interface Listener { /** Waits for and resolves to the next connection to the `Listener`. */ accept(): Promise<Conn>; /** Close closes the listener. Any pending accept promises will be rejected * with errors. */ close(): void; /** Return the address of the `Listener`. */ addr(): Addr; } export interface Conn extends Reader, Writer, Closer { /** The local address of the connection. */ localAddr: string; /** The remote address of the connection. */ remoteAddr: string; /** 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; } /** Listen announces on the local network address. * * The network must be `tcp`, `tcp4`, `tcp6`, `unix` or `unixpacket`. * * For TCP networks, if the host in the address parameter is empty or a literal * unspecified IP address, `listen()` listens on all available unicast and * anycast IP addresses of the local system. To only use IPv4, use network * `tcp4`. The address can use a host name, but this is not recommended, * because it will create a listener for at most one of the host's IP * addresses. If the port in the address parameter is empty or `0`, as in * `127.0.0.1:` or `[::1]:0`, a port number is automatically chosen. The * `addr()` method of `Listener` can be used to discover the chosen port. * * See `dial()` for a description of the network and address parameters. */ export function listen(network: Network, address: string): Listener; /** Dial connects to the address on the named network. * * Supported networks are only `tcp` currently. * * TODO: `tcp4` (IPv4-only), `tcp6` (IPv6-only), `udp`, `udp4` (IPv4-only), * `udp6` (IPv6-only), `ip`, `ip4` (IPv4-only), `ip6` (IPv6-only), `unix`, * `unixgram` and `unixpacket`. * * For TCP and UDP networks, the address has the form `host:port`. The host must * be a literal IP address, or a host name that can be resolved to IP addresses. * The port must be a literal port number or a service name. If the host is a * literal IPv6 address it must be enclosed in square brackets, as in * `[2001:db8::1]:80` or `[fe80::1%zone]:80`. The zone specifies the scope of * the literal IPv6 address as defined in RFC 4007. The functions JoinHostPort * and SplitHostPort manipulate a pair of host and port in this form. When using * TCP, and the host resolves to multiple IP addresses, Dial will try each IP * address in order until one succeeds. * * Examples: * * dial("tcp", "golang.org:http") * dial("tcp", "192.0.2.1:http") * dial("tcp", "198.51.100.1:80") * dial("udp", "[2001:db8::1]:domain") * dial("udp", "[fe80::1%lo0]:53") * dial("tcp", ":80") */ export function dial(network: Network, address: string): Promise<Conn>; /** **RESERVED** */ export function connect(network: Network, address: string): Promise<Conn>;
// @url js/metrics.d.ts
interface Metrics { opsDispatched: number; opsCompleted: number; bytesSentControl: number; bytesSentData: number; bytesReceived: number; } /** Receive metrics from the privileged side of Deno. */ export function metrics(): Metrics; export {};
// @url js/resources.d.ts
type 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 subsubprocess 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; stdout?: ProcessStdio; stderr?: ProcessStdio; stdin?: ProcessStdio; } export class Process { readonly rid: number; readonly pid: number; readonly stdin?: WriteCloser; readonly stdout?: ReadCloser; readonly stderr?: ReadCloser; status(): Promise<ProcessStatus>; /** Buffer the stdout and return it as Uint8Array after EOF. * You must have set stdout to "piped" in when creating the process. * This calls close() on stdout after its done. */ output(): Promise<Uint8Array>; close(): void; } export interface ProcessStatus { success: boolean; code?: number; signal?: number; } export function run(opt: RunOptions): Process;
// @url js/console.d.ts
type ConsoleOptions = Partial<{ showHidden: boolean; depth: number; colors: boolean; }>; /** TODO Do not expose this from "deno" namespace. */ export function stringifyArgs(args: any[], options?: ConsoleOptions): string; type PrintFunc = (x: string, isErr?: boolean) => void; /** TODO Do not expose this from "deno". */ export class Console { private printFunc; constructor(printFunc: PrintFunc); /** Writes the arguments to stdout */ log: (...args: any[]) => void; /** Writes the arguments to stdout */ debug: (...args: any[]) => void; /** Writes the arguments to stdout */ info: (...args: any[]) => void; /** Writes the properties of the supplied `obj` to stdout */ dir: ( obj: any, options?: Partial<{ showHidden: boolean; depth: number; colors: boolean; }> ) => void; /** Writes the arguments to stdout */ warn: (...args: any[]) => void; /** Writes the arguments to stdout */ error: (...args: any[]) => 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: any[]) => void; count: (label?: string) => void; countReset: (label?: string) => void; time: (label?: string) => void; timeLog: (label?: string, ...args: any[]) => void; timeEnd: (label?: string) => void; } /** * inspect() converts input into string that has the same format * as printed by console.log(...); */ export function inspect( value: any, // tslint:disable-line:no-any options?: ConsoleOptions ): string; export {};
// @url js/dom_types.d.ts
/*! **************************************************************************** Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABLITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions and limitations under the License. *******************************************************************************/ type BufferSource = ArrayBufferView | ArrayBuffer; type HeadersInit = Headers | Array<[string, string]> | Record<string, string>; type URLSearchParamsInit = string | string[][] | Record<string, string>; type BodyInit = | Blob | BufferSource | FormData | URLSearchParams | ReadableStream | string; type RequestInfo = Request | string; type ReferrerPolicy = | "" | "no-referrer" | "no-referrer-when-downgrade" | "origin-only" | "origin-when-cross-origin" | "unsafe-url"; type BlobPart = BufferSource | Blob | string; type FormDataEntryValue = DomFile | string; type EventListenerOrEventListenerObject = EventListener | EventListenerObject; interface DomIterable<K, V> { keys(): IterableIterator<K>; values(): IterableIterator<V>; entries(): IterableIterator<[K, V]>; [Symbol.iterator](): IterableIterator<[K, V]>; forEach( callback: (value: V, key: K, parent: this) => void, thisArg?: any ): void; } interface Element {} interface HTMLFormElement {} type EndingType = "transparent" | "native"; interface BlobPropertyBag { type?: string; ending?: EndingType; } interface AbortSignalEventMap { abort: ProgressEvent; } interface EventTarget { addEventListener( type: string, listener: EventListenerOrEventListenerObject | null, options?: boolean | AddEventListenerOptions ): void; dispatchEvent(evt: Event): boolean; removeEventListener( type: string, listener?: EventListenerOrEventListenerObject | null, options?: EventListenerOptions | boolean ): void; } interface ProgressEventInit extends EventInit { lengthComputable?: boolean; loaded?: number; total?: number; } interface URLSearchParams { /** * 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: URLSearchParams) => void, thisArg?: any ): void; } interface EventListener { (evt: Event): void; } interface EventInit { bubbles?: boolean; cancelable?: boolean; composed?: boolean; } interface Event { readonly bubbles: boolean; cancelBubble: boolean; readonly cancelable: boolean; readonly composed: boolean; readonly currentTarget: EventTarget | null; readonly defaultPrevented: boolean; readonly eventPhase: number; readonly isTrusted: boolean; returnValue: boolean; readonly srcElement: Element | null; readonly target: EventTarget | null; readonly timeStamp: number; readonly type: string; deepPath(): EventTarget[]; initEvent(type: string, bubbles?: boolean, cancelable?: boolean): void; preventDefault(): void; stopImmediatePropagation(): void; stopPropagation(): void; readonly AT_TARGET: number; readonly BUBBLING_PHASE: number; readonly CAPTURING_PHASE: number; readonly NONE: number; } interface DomFile extends Blob { readonly lastModified: number; readonly name: string; } interface FilePropertyBag extends BlobPropertyBag { lastModified?: number; } interface ProgressEvent extends Event { readonly lengthComputable: boolean; readonly loaded: number; readonly total: number; } interface EventListenerOptions { capture?: boolean; } interface AddEventListenerOptions extends EventListenerOptions { once?: boolean; passive?: boolean; } interface AbortSignal extends EventTarget { readonly aborted: boolean; onabort: ((this: AbortSignal, ev: ProgressEvent) => any) | null; addEventListener<K extends keyof AbortSignalEventMap>( type: K, listener: (this: AbortSignal, ev: AbortSignalEventMap[K]) => any, options?: boolean | AddEventListenerOptions ): void; addEventListener( type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions ): void; removeEventListener<K extends keyof AbortSignalEventMap>( type: K, listener: (this: AbortSignal, ev: AbortSignalEventMap[K]) => any, options?: boolean | EventListenerOptions ): void; removeEventListener( type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions ): void; } interface ReadableStream { readonly locked: boolean; cancel(): Promise<void>; getReader(): ReadableStreamReader; } interface EventListenerObject { handleEvent(evt: Event): void; } interface ReadableStreamReader { cancel(): Promise<void>; read(): Promise<any>; releaseLock(): void; } interface FormData extends DomIterable<string, FormDataEntryValue> { 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; } interface FormDataConstructor { new (): FormData; prototype: FormData; } /** A blob object represents a file-like object of immutable, raw data. */ 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; } 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<ArrayBuffer>; /** Takes a `Response` stream and reads it to completion. It returns a promise * that resolves with a `Blob`. */ blob(): Promise<Blob>; /** Takes a `Response` stream and reads it to completion. It returns a promise * that resolves with a `FormData` object. */ formData(): Promise<FormData>; /** 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<any>; /** Takes a `Response` stream and reads it to completion. It returns a promise * that resolves with a `USVString` (text). */ text(): Promise<string>; } interface Headers extends DomIterable<string, string> { /** 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<string>; /** 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<string>; 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]>; } 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"; 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; } interface ResponseInit { headers?: HeadersInit; status?: number; statusText?: string; } 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; } 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<Headers>; /** 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 {};
// @url js/mixins/dom_iterable.d.ts
type Constructor<T = {}> = new (...args: any[]) => T; /** Mixes in a DOM iterable methods into a base class, assumes that there is * a private data iterable that is part of the base class, located at * `[dataSymbol]`. * TODO Don't expose DomIterableMixin from "deno" namespace. */ export function DomIterableMixin<K, V, TBase extends Constructor>( Base: TBase, dataSymbol: symbol ): TBase & Constructor<DomIterable<K, V>>; export {};
// @url js/types.d.ts
type TypedArray = Uint8Array | Float32Array | Int32Array; interface CallSite { /** Value of `this` */ getThis(): any; /** Type of `this` as a string. * * This is the name of the function stored in the constructor field of * `this`, if available. Otherwise the object's `[[Class]]` internal * property. */ getTypeName(): string | null; /** Current function. */ getFunction(): Function | undefined; /** Name of the current function, typically its name property. * * If a name property is not available an attempt will be made to try * to infer a name from the function's context. */ getFunctionName(): string | null; /** Name of the property (of `this` or one of its prototypes) that holds * the current function. */ getMethodName(): string | null; /** Name of the script (if this function was defined in a script). */ getFileName(): string | null; /** Get the script name or source URL for the source map. */ getScriptNameOrSourceURL(): string; /** Current line number (if this function was defined in a script). */ getLineNumber(): number | null; /** Current column number (if this function was defined in a script). */ getColumnNumber(): number | null; /** A call site object representing the location where eval was called (if * this function was created using a call to `eval`) */ getEvalOrigin(): string | undefined; /** Is this a top level invocation, that is, is `this` the global object? */ isToplevel(): boolean; /** Does this call take place in code defined by a call to `eval`? */ isEval(): boolean; /** Is this call in native V8 code? */ isNative(): boolean; /** Is this a constructor call? */ isConstructor(): boolean; } interface StartOfSourceMap { file?: string; sourceRoot?: string; } interface RawSourceMap extends StartOfSourceMap { version: string; sources: string[]; names: string[]; sourcesContent?: string[]; mappings: string; } global { interface ErrorConstructor { /** Create `.stack` property on a target object */ captureStackTrace(targetObject: object, constructorOpt?: Function): void; /** * Optional override for formatting stack traces * * @see https://github.com/v8/v8/wiki/Stack%20Trace%20API#customizing-stack-traces */ prepareStackTrace?: (err: Error, stackTraces: CallSite[]) => any; stackTraceLimit: number; } }
// @url js/util.d.ts
interface Deferred { promise: Promise<void>; resolve: Function; reject: Function; } /** Create a wrapper around a promise that could be resolved externally. * TODO Do not expose this from "deno" namespace. */ export function deferred(): Deferred; function isTypedArray(x: unknown): x is TypedArray;
// @url js/deno.d.ts
export const args: string[];}
declare interface Window { window: Window; atob: typeof textEncoding.atob; btoa: typeof textEncoding.btoa; fetch: typeof fetchTypes.fetch; clearTimeout: typeof timers.clearTimer; clearInterval: typeof timers.clearTimer; console: consoleTypes.Console; setTimeout: typeof timers.setTimeout; setInterval: typeof timers.setInterval; Blob: typeof blob.DenoBlob; URL: typeof url.URL; URLSearchParams: typeof urlSearchParams.URLSearchParams; Headers: domTypes.HeadersConstructor; FormData: domTypes.FormDataConstructor; TextEncoder: typeof textEncoding.TextEncoder; TextDecoder: typeof textEncoding.TextDecoder;}
declare const window: Window;declare const atob: typeof textEncoding.atob;declare const btoa: typeof textEncoding.btoa;declare const fetch: typeof fetchTypes.fetch;declare const clearTimeout: typeof timers.clearTimer;declare const clearInterval: typeof timers.clearTimer;declare const console: consoleTypes.Console;declare const setTimeout: typeof timers.setTimeout;declare const setInterval: typeof timers.setInterval;declare const Blob: typeof blob.DenoBlob;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 type Blob = blob.DenoBlob;declare type URL = url.URL;declare type URLSearchParams = urlSearchParams.URLSearchParams;declare type Headers = domTypes.Headers;declare type FormData = domTypes.FormData;declare type TextEncoder = textEncoding.TextEncoder;declare type TextDecoder = textEncoding.TextDecoder;
declare namespace domTypes { // @url js/dom_types.d.ts
type BufferSource = ArrayBufferView | ArrayBuffer; type HeadersInit = Headers | Array<[string, string]> | Record<string, string>; type URLSearchParamsInit = string | string[][] | Record<string, string>; type BodyInit = | Blob | BufferSource | FormData | URLSearchParams | ReadableStream | string; type RequestInfo = Request | string; type ReferrerPolicy = | "" | "no-referrer" | "no-referrer-when-downgrade" | "origin-only" | "origin-when-cross-origin" | "unsafe-url"; type BlobPart = BufferSource | Blob | string; type FormDataEntryValue = DomFile | string; type EventListenerOrEventListenerObject = EventListener | EventListenerObject; interface DomIterable<K, V> { keys(): IterableIterator<K>; values(): IterableIterator<V>; entries(): IterableIterator<[K, V]>; [Symbol.iterator](): IterableIterator<[K, V]>; forEach( callback: (value: V, key: K, parent: this) => void, thisArg?: any ): void; } interface Element {} interface HTMLFormElement {} type EndingType = "transparent" | "native"; interface BlobPropertyBag { type?: string; ending?: EndingType; } interface AbortSignalEventMap { abort: ProgressEvent; } interface EventTarget { addEventListener( type: string, listener: EventListenerOrEventListenerObject | null, options?: boolean | AddEventListenerOptions ): void; dispatchEvent(evt: Event): boolean; removeEventListener( type: string, listener?: EventListenerOrEventListenerObject | null, options?: EventListenerOptions | boolean ): void; } interface ProgressEventInit extends EventInit { lengthComputable?: boolean; loaded?: number; total?: number; } interface URLSearchParams { /** * 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: URLSearchParams) => void, thisArg?: any ): void; } interface EventListener { (evt: Event): void; } interface EventInit { bubbles?: boolean; cancelable?: boolean; composed?: boolean; } interface Event { readonly bubbles: boolean; cancelBubble: boolean; readonly cancelable: boolean; readonly composed: boolean; readonly currentTarget: EventTarget | null; readonly defaultPrevented: boolean; readonly eventPhase: number; readonly isTrusted: boolean; returnValue: boolean; readonly srcElement: Element | null; readonly target: EventTarget | null; readonly timeStamp: number; readonly type: string; deepPath(): EventTarget[]; initEvent(type: string, bubbles?: boolean, cancelable?: boolean): void; preventDefault(): void; stopImmediatePropagation(): void; stopPropagation(): void; readonly AT_TARGET: number; readonly BUBBLING_PHASE: number; readonly CAPTURING_PHASE: number; readonly NONE: number; } interface DomFile extends Blob { readonly lastModified: number; readonly name: string; } interface FilePropertyBag extends BlobPropertyBag { lastModified?: number; } interface ProgressEvent extends Event { readonly lengthComputable: boolean; readonly loaded: number; readonly total: number; } interface EventListenerOptions { capture?: boolean; } interface AddEventListenerOptions extends EventListenerOptions { once?: boolean; passive?: boolean; } interface AbortSignal extends EventTarget { readonly aborted: boolean; onabort: ((this: AbortSignal, ev: ProgressEvent) => any) | null; addEventListener<K extends keyof AbortSignalEventMap>( type: K, listener: (this: AbortSignal, ev: AbortSignalEventMap[K]) => any, options?: boolean | AddEventListenerOptions ): void; addEventListener( type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions ): void; removeEventListener<K extends keyof AbortSignalEventMap>( type: K, listener: (this: AbortSignal, ev: AbortSignalEventMap[K]) => any, options?: boolean | EventListenerOptions ): void; removeEventListener( type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions ): void; } interface ReadableStream { readonly locked: boolean; cancel(): Promise<void>; getReader(): ReadableStreamReader; } interface EventListenerObject { handleEvent(evt: Event): void; } interface ReadableStreamReader { cancel(): Promise<void>; read(): Promise<any>; releaseLock(): void; } interface FormData extends DomIterable<string, FormDataEntryValue> { 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; } interface FormDataConstructor { new (): FormData; prototype: FormData; } /** A blob object represents a file-like object of immutable, raw data. */ 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; } 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<ArrayBuffer>; /** Takes a `Response` stream and reads it to completion. It returns a promise * that resolves with a `Blob`. */ blob(): Promise<Blob>; /** Takes a `Response` stream and reads it to completion. It returns a promise * that resolves with a `FormData` object. */ formData(): Promise<FormData>; /** 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<any>; /** Takes a `Response` stream and reads it to completion. It returns a promise * that resolves with a `USVString` (text). */ text(): Promise<string>; } interface Headers extends DomIterable<string, string> { /** 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<string>; /** 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<string>; 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]>; } 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"; 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; } interface ResponseInit { headers?: HeadersInit; status?: number; statusText?: string; } 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; } 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<Headers>; /** 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; }}
declare namespace blob { // @url js/blob.d.ts
const bytesSymbol: unique symbol; 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 consoleTypes { // @url js/console.d.ts
type ConsoleOptions = Partial<{ showHidden: boolean; depth: number; colors: boolean; }>; /** TODO Do not expose this from "deno" namespace. */ export function stringifyArgs(args: any[], options?: ConsoleOptions): string; type PrintFunc = (x: string, isErr?: boolean) => void; /** TODO Do not expose this from "deno". */ export class Console { private printFunc; constructor(printFunc: PrintFunc); /** Writes the arguments to stdout */ log: (...args: any[]) => void; /** Writes the arguments to stdout */ debug: (...args: any[]) => void; /** Writes the arguments to stdout */ info: (...args: any[]) => void; /** Writes the properties of the supplied `obj` to stdout */ dir: ( obj: any, options?: Partial<{ showHidden: boolean; depth: number; colors: boolean; }> ) => void; /** Writes the arguments to stdout */ warn: (...args: any[]) => void; /** Writes the arguments to stdout */ error: (...args: any[]) => 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: any[]) => void; count: (label?: string) => void; countReset: (label?: string) => void; time: (label?: string) => void; timeLog: (label?: string, ...args: any[]) => void; timeEnd: (label?: string) => void; } /** * inspect() converts input into string that has the same format * as printed by console.log(...); */ export function inspect( value: any, // tslint:disable-line:no-any options?: ConsoleOptions ): string;}
declare namespace io { // @url js/io.d.ts
export interface ReadResult { nread: number; eof: boolean; } export interface Reader { /** Reads up to p.byteLength bytes into `p`. It resolves to the number * of bytes read (`0` <= `n` <= `p.byteLength`) and 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 an error or end-of-file condition after * successfully reading `n` > `0` bytes, it returns the number of bytes read. * It may return the (non-nil) error from the same call or return the error * (and `n` == `0`) from a subsequent call. An instance of this general case * is that a `Reader` returning a non-zero number of bytes at the end of the * input stream may return either `err` == `EOF` or `err` == `null`. The next * `read()` should return `0`, `EOF`. * * 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 of `read()` are discouraged from returning a zero byte * count with a `null` error, except when `p.byteLength` == `0`. Callers * should treat a return of `0` and `null` as indicating that nothing * happened; in particular it does not indicate `EOF`. * * Implementations must not retain `p`. */ read(p: Uint8Array): Promise<ReadResult>; } 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<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: number): Promise<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<number>; /** Turns `r` into async iterator. * * for await (const chunk of readerIterator(reader)) { * console.log(chunk) * } */ export function toAsyncIterator(r: Reader): AsyncIterableIterator<Uint8Array>;}
declare namespace fetchTypes { // @url js/fetch.d.ts
class Body implements domTypes.Body, domTypes.ReadableStream, io.ReadCloser { private rid; readonly contentType: string; bodyUsed: boolean; private _bodyPromise; private _data; readonly locked: boolean; readonly body: null | Body; constructor(rid: number, contentType: string); private _bodyBuffer; arrayBuffer(): Promise<ArrayBuffer>; blob(): Promise<domTypes.Blob>; formData(): Promise<domTypes.FormData>; json(): Promise<any>; text(): Promise<string>; read(p: Uint8Array): Promise<io.ReadResult>; close(): void; cancel(): Promise<void>; getReader(): domTypes.ReadableStreamReader; } class Response implements domTypes.Response { readonly status: number; readonly url: string; statusText: string; readonly type = "basic"; redirected: boolean; headers: domTypes.Headers; readonly trailer: Promise<domTypes.Headers>; bodyUsed: boolean; readonly body: Body; constructor( status: number, headersList: Array<[string, string]>, rid: number, body_?: null | Body ); arrayBuffer(): Promise<ArrayBuffer>; blob(): Promise<domTypes.Blob>; formData(): Promise<domTypes.FormData>; json(): Promise<any>; text(): Promise<string>; readonly ok: boolean; clone(): domTypes.Response; } /** Fetch a resource from the network. */ export function fetch( input: domTypes.Request | string, init?: domTypes.RequestInit ): Promise<Response>;}
declare namespace textEncoding { // @url js/text_encoding.d.ts
export function atob(s: string): string; /** Creates a base-64 ASCII string from the input string. */ export function btoa(s: string): string; export interface TextDecodeOptions { stream?: false; } export interface TextDecoderOptions { fatal?: boolean; ignoreBOM?: false; } export class TextDecoder { private _encoding; /** Returns encoding's name, lowercased. */ readonly encoding: string; /** Returns `true` if error mode is "fatal", and `false` otherwise. */ readonly fatal: boolean; /** Returns `true` if ignore BOM flag is set, and `false` otherwise. */ readonly ignoreBOM = false; constructor(label?: string, options?: TextDecoderOptions); /** Returns the result of running encoding's decoder. */ decode(input?: domTypes.BufferSource, options?: TextDecodeOptions): string; } export class TextEncoder { /** Returns "utf-8". */ readonly encoding = "utf-8"; /** Returns the result of running UTF-8's encoder. */ encode(input?: string): Uint8Array; }}
declare namespace timers { // @url js/timers.d.ts
export type Args = any[]; /** Sets a timer which executes a function once after the timer expires. */ export function setTimeout( cb: (...args: Args) => void, delay: number, ...args: Args ): number; /** Repeatedly calls a function , with a fixed time delay between each call. */ export function setInterval( cb: (...args: Args) => void, delay: number, ...args: Args ): number; /** Clears a previously set timer by id. */ export function clearTimer(id: number): void;}
declare namespace urlSearchParams { // @url js/url_search_params.d.ts
export class URLSearchParams { private params; constructor(init?: string | string[][] | Record<string, string>); /** Appends a specified key/value pair as a new search parameter. * * searchParams.append('name', 'first'); * searchParams.append('name', 'second'); */ append(name: string, value: string): void; /** Deletes the given search parameter and its associated value, * from the list of all search parameters. * * searchParams.delete('name'); */ delete(name: string): void; /** Returns all the values associated with a given search parameter * as an array. * * searchParams.getAll('name'); */ getAll(name: string): string[]; /** Returns the first value associated to the given search parameter. * * searchParams.get('name'); */ get(name: string): string | null; /** Returns a Boolean that indicates whether a parameter with the * specified name exists. * * searchParams.has('name'); */ has(name: string): boolean; /** Sets the value associated with a given search parameter to the * given value. If there were several matching values, this method * deletes the others. If the search parameter doesn't exist, this * method creates it. * * searchParams.set('name', 'value'); */ 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. * * searchParams.sort(); */ sort(): void; /** Calls a function for each element contained in this object in * place and return undefined. Optionally accepts an object to use * as this when executing callback as second argument. * * searchParams.forEach((value, key, parent) => { * console.log(value, key, parent); * }); * */ forEach( callbackfn: (value: string, key: string, parent: URLSearchParams) => void, thisArg?: any ): void; /** Returns an iterator allowing to go through all keys contained * in this object. * * for (const key of searchParams.keys()) { * console.log(key); * } */ keys(): Iterable<string>; /** Returns an iterator allowing to go through all values contained * in this object. * * for (const value of searchParams.values()) { * console.log(value); * } */ values(): Iterable<string>; /** Returns an iterator allowing to go through all key/value * pairs contained in this object. * * for (const [key, value] of searchParams.entries()) { * console.log(key, value); * } */ entries(): Iterable<[string, string]>; /** Returns an iterator allowing to go through all key/value * pairs contained in this object. * * for (const [key, value] of searchParams[Symbol.iterator]()) { * console.log(key, value); * } */ [Symbol.iterator](): Iterable<[string, string]>; /** Returns a query string suitable for use in a URL. * * searchParams.toString(); */ toString(): string; }}
declare namespace url { // @url js/url.d.ts
export class URL { private _parts; private _searchParams; private _updateSearchParams; hash: string; host: string; hostname: string; href: string; readonly origin: string; password: string; pathname: string; port: string; protocol: string; search: string; username: string; readonly searchParams: urlSearchParams.URLSearchParams; constructor(url: string, base?: string | URL); toString(): string; toJSON(): string; }}