Skip to main content

There are APIs that are built into the Deno CLI that are beyond those that are built-ins for JavaScript. They are a combination of web platform APIs Deno has implemented and Deno specific APIs.

We try to keep non-standard, Deno specific, APIs in the Deno namespace. We have grouped the APIs into the following functional categories.

Uncategorized

A controller object that allows you to abort one or more DOM requests as and when desired.

This Streams API interface provides a built-in byte length queuing strategy that can be used when constructing streams.

A variable-sized buffer of bytes with read() and write() methods.

The Deno abstraction for reading and writing files.

An event which takes place in the DOM.

EventTarget is a DOM interface implemented by objects that can receive events and may have listeners for them.

Indicates an error during WebAssembly decoding or validation

Represents a global variable instance, accessible from both JavaScript and importable/exportable across one or more WebAssembly.Module instances. This allows dynamic linking of multiple modules.

Indicates an error during module instantiation (besides traps from the start function).

Is thrown whenever WebAssembly specifies a trap.

This Streams API interface provides a standard abstraction for writing streaming data to a destination, known as a sink. This object comes with built-in backpressure and queuing.

A signal object that allows you to communicate with a DOM request (such as a Fetch) and abort it if required via an AbortController object.

A file-like object of immutable, raw data. Blobs represent data that isn't necessarily in a JavaScript-native format. The File interface is based on Blob, inheriting blob functionality and expanding it to support files on the user's system.

A FileInfo describes a file and is returned by stat, lstat, statSync, lstatSync.

A generic network listener for stream-oriented protocols.

Options for writing to a file.

Provides information about files and allows JavaScript in a web page to access their content.

Provides a way to easily construct a set of key/value pairs representing form fields and their values, which can then be easily sent using the XMLHttpRequest.send() method. It uses the same format a form would use if the encoding type were set to "multipart/form-data".

This Fetch API interface allows you to perform various actions on HTTP request and response headers. These actions include retrieving, setting, adding to, and removing. A Headers object has an associated header list, which is initially empty and consists of zero or more name and value pairs.  You can add to this using methods like append() (see Examples.) In all methods of this interface, header names are matched by case-insensitive byte sequence.

Events measuring progress of an underlying process, like an HTTP request (for an XMLHttpRequest, or the loading of the underlying resource of an , , , or ).

This Streams API interface represents a readable stream of byte data. The Fetch API offers a concrete instance of a ReadableStream through the body property of a Response object.

This Fetch API interface represents a resource request.

This Fetch API interface represents the response to a request.

I
v
URL

The URL interface represents an object providing static methods used for creating object URLs.

This Streams API interface represents a controller allowing control of a WritableStream's state. When constructing a WritableStream, the underlying sink is given a corresponding WritableStreamDefaultController instance to manipulate.

This Streams API interface is the object returned by WritableStream.getWriter() and once created locks the < writer to the WritableStream ensuring that no other streams can write to the underlying sink.

Returns the script arguments to the program. If for example we run a program:

Build related information.

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.

A set of error constructors that are raised by Deno APIs.

Reflects the NO_COLOR environment variable.

The current process id of the runtime.

A handle for stderr.

A handle for stdin.

A handle for stdout.

Version related information.

Creates a base-64 ASCII string from the input string.

Change the current working directory to the specified path.

Changes the permission of a specific file/directory of specified path. Ignores the process's umask.

Synchronously changes the permission of a specific file/directory of specified path. Ignores the process's umask.

Change owner of a regular file or directory. This functionality is not available on Windows.

Synchronously change owner of a regular file or directory. This functionality is not available on Windows.

Close the given resource ID (rid) which has been previously opened, such as via opening or creating a file. Closing a file when you are finished with it is important to avoid leaking resources.

Connects to the hostname (default is "127.0.0.1") and port on the named transport (default is "tcp"), and resolves to the connection (Conn).

Establishes a secure connection over TLS (transport layer security) using an optional cert file, hostname (default is "127.0.0.1") and port. The cert file is optional and if not included Mozilla's root certificates will be used (see also https://github.com/ctz/webpki-roots for specifics)

Copies from src to dst until either EOF (null) is read from src or an error occurs. It resolves to the number of bytes copied or rejects with the first error encountered while copying.

Copies the contents and permissions of one file to another specified path, by default creating a new file if needed, else overwriting. Fails if target path is a directory or is unwritable.

Synchronously copies the contents and permissions of one file to another specified path, by default creating a new file if needed, else overwriting. Fails if target path is a directory or is unwritable.

Creates a file if none exists or truncates an existing file and resolves to an instance of Deno.File.

Creates a file if none exists or truncates an existing file and returns an instance of Deno.File.

Return a string representing the current working directory.

Returns the path to the current deno executable.

Exit the Deno process with optional exit code. If no exit code is supplied then Deno will exit with return code of 0.

Converts the input into a string that has the same format as printed by console.log().

Check if a given resource id (rid) is a TTY.

Turns a Reader, r, into an async iterator.

Turns a ReaderSync, r, into an iterator.

Listen announces on the local transport address.

Listen announces on the local transport address over TLS (transport layer security).

Resolves to a Deno.FileInfo for the specified path. If path is a symlink, information for the symlink will be returned instead of what it points to.

Synchronously returns a Deno.FileInfo for the specified path. If path is a symlink, information for the symlink will be returned instead of what it points to..

Creates a new temporary directory in the default directory for temporary files (see also Deno.dir("temp")), unless dir is specified. Other optional options include prefixing and suffixing the directory name with prefix and suffix respectively.

Synchronously creates a new temporary directory in the default directory for temporary files (see also Deno.dir("temp")), unless dir is specified. Other optional options include prefixing and suffixing the directory name with prefix and suffix respectively.

Creates a new temporary file in the default directory for temporary files (see also Deno.dir("temp")), unless dir is specified. Other optional options include prefixing and suffixing the directory name with prefix and suffix respectively.

Synchronously creates a new temporary file in the default directory for temporary files (see also Deno.dir("temp")), unless dir is specified. Other optional options include prefixing and suffixing the directory name with prefix and suffix respectively.

Receive metrics from the privileged side of Deno. This is primarily used in the development of Deno. 'Ops', also called 'bindings', are the go-between between Deno Javascript and Deno Rust.

Creates a new directory with the specified path.

Synchronously creates a new directory with the specified path.

Open a file and resolve to an instance of Deno.File. The file does not need to previously exist if using the create or createNew open options. It is the callers responsibility to close the file when finished with it.

Synchronously open a file and return an instance of Deno.File. The file does not need to previously exist if using the create or createNew open options. It is the callers responsibility to close the file when finished with it.

Read from a resource ID (rid) into an array buffer (buffer).

Read Reader r until EOF (null) and resolve to the content as Uint8Array`.

Synchronously reads Reader r until EOF (null) and returns the content as Uint8Array.

Reads the directory given by path and returns an async iterable of Deno.DirEntry.

Synchronously reads the directory given by path and returns an iterable of Deno.DirEntry.

Reads and resolves to the entire contents of a file as an array of bytes. TextDecoder can be used to transform the bytes to string if required. Reading a directory returns an empty data array.

Synchronously reads and returns the entire contents of a file as an array of bytes. TextDecoder can be used to transform the bytes to string if required. Reading a directory returns an empty data array.

Resolves to the full path destination of the named symbolic link.

Returns the full path destination of the named symbolic link.

Synchronously read from a resource ID (rid) into an array buffer (buffer).

Asynchronously reads and returns the entire contents of a file as a utf8 encoded string. Reading a directory returns an empty data array.

Synchronously reads and returns the entire contents of a file as utf8 encoded string encoded string. Reading a directory returns an empty string.

Resolves to the absolute normalized path, with symbolic links resolved.

Returns absolute normalized path, with symbolic links resolved.

Removes the named file or directory.

Synchronously removes the named file or directory.

Renames (moves) oldpath to newpath. Paths may be files or directories. 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.

Synchronously renames (moves) oldpath to newpath. Paths may be files or directories. 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.

Returns a map of open resource ids (rid) along with their string representations. This is an internal API and as such resource representation has any type; that means it can change any time.

Spawns new subprocess. RunOptions must contain at a minimum the opt.cmd, an array of program arguments, the first of which is the binary.

Seek a resource ID (rid) to the given offset under mode given by whence. The call resolves to the new position within the resource (bytes from the start).

Synchronously seek a resource ID (rid) to the given offset under mode given by whence. The new position within the resource (bytes from the start) is returned.

Resolves to a Deno.FileInfo for the specified path. Will always follow symlinks.

Synchronously returns a Deno.FileInfo for the specified path. Will always follow symlinks.

Register a test which will be run when deno test is used on the command line and the containing module looks like a test module. fn can be async if required.

Truncates or extends the specified file, to reach the specified len. If len is not specified then the entire file contents are truncated.

Synchronously truncates or extends the specified file, to reach the specified len. If len is not specified then the entire file contents are truncated.

Watch for file system events against one or more paths, which can be files or directories. These paths must exist already. One user action (e.g. touch test.file) can generate multiple file system events. Likewise, one user action can result in multiple file paths in one event (e.g. mv old_name.txt new_name.txt). Recursive option is true by default and, for directories, will watch the specified directory and all sub directories. Note that the exact ordering of the events can vary between operating systems.

Write to the resource ID (rid) the contents of the array buffer (data).

Write all the content of the array buffer (arr) to the writer (w).

Synchronously write all the content of the array buffer (arr) to the writer (w).

Write data to the given path, by default creating a new file if needed, else overwriting.

Synchronously write data to the given path, by default creating a new file if needed, else overwriting.

Synchronously write to the resource ID (rid) the contents of the array buffer (data).

Asynchronously write string data to the given path, by default creating a new file if needed, else overwriting.

Synchronously write string data to the given path, by default creating a new file if needed, else overwriting.

Fetch a resource from the network.

Returns a current time from Deno's start in milliseconds.

Repeatedly calls a function , with a fixed time delay between each call.

Sets a timer which executes a function once after the timer expires.

Compiles a WebAssembly.Module from WebAssembly binary code. This function is useful if it is necessary to a compile a module before it can be instantiated (otherwise, the WebAssembly.instantiate() function should be used).

Compiles a WebAssembly.Module directly from a streamed underlying source. This function is useful if it is necessary to a compile a module before it can be instantiated (otherwise, the WebAssembly.instantiateStreaming() function should be used).

Takes the WebAssembly binary code, in the form of a typed array or ArrayBuffer, and performs both compilation and instantiation in one step. The returned Promise resolves to both a compiled WebAssembly.Module and its first WebAssembly.Instance.

Compiles and instantiates a WebAssembly module directly from a streamed underlying source. This is the most efficient, optimized way to load wasm code.

Validates a given typed array of WebAssembly binary code, returning whether the bytes form a valid wasm module (true) or not (false).