Skip to main content
namespace Deno

The global namespace where Deno specific, non-standard APIs are located.

Namespaces

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

Classes

c
Deno.Buffer
deprecated

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

Raised when attempting to open a server listener on an address and port that already has a listener.

Raised when the underlying operating system reports an EADDRNOTAVAIL error.

Raised when trying to create a resource, like a file, that already exits.

The underlying IO resource is invalid or closed, and so the operation could not be performed.

Raised when trying to write to a resource and a broken pipe error occurs. This can happen when trying to write directly to stdout or stderr and the operating system is unable to pipe the output for a reason external to the Deno runtime.

Raised when the underlying IO resource is not available because it is being awaited on in another block of code.

Raised when the underlying operating system reports an ECONNABORTED error.

Raised when the underlying operating system reports that a connection to a resource is refused.

Raised when the underlying operating system reports that a connection has been reset. With network servers, it can be a normal occurrence where a client will abort a connection instead of properly shutting it down.

Raised in situations where when attempting to load a dynamic import, too many redirects were encountered.

Raised when the underlying operating system reports an EINTR error. In many cases, this underlying IO error will be handled internally within Deno, or result in an @{link BadResource} error instead.

Raised when an operation to returns data that is invalid for the operation being performed.

Raised when the underlying operating system reports an ENOTCONN error.

Raised when the underlying operating system indicates that the file was not found.

Raised when the underlying Deno API is asked to perform a function that is not currently supported.

Raised when the underlying operating system indicates the current user which the Deno process is running under does not have the appropriate permissions to a file or resource, or the user did not provide required --allow-* flag.

Raised when the underlying operating system reports that an I/O operation has timed out (ETIMEDOUT).

Raised when attempting to read bytes from a resource, but the EOF was unexpectedly encountered.

Raised when expecting to write to a IO buffer resulted in zero bytes being written.

The Deno abstraction for reading and writing files.

Represents an instance of a sub process that is returned from Deno.run which can be used to manage the sub-process.

Enums

A enum which defines the seek mode for IO related APIs that support seeking.

Variables

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.

An interface containing methods to interact with the process environment variables.

v
Deno.File
deprecated

The Deno abstraction for reading and writing files.

The URL of the entrypoint module entered from the command-line.

Reflects the NO_COLOR environment variable at program start.

Deno's permission management API.

The current process ID of this instance of the Deno CLI.

The process ID of parent process of this instance of the Deno CLI.

A reference to stderr which can be used to write directly to stderr. It implements the Deno specific Writer, WriterSync, and Closer interfaces as well as provides a WritableStream interface.

A reference to stdin which can be used to read directly from stdin. It implements the Deno specific Reader, ReaderSync, and Closer interfaces as well as provides a ReadableStream interface.

A reference to stdout which can be used to write directly to stdout. It implements the Deno specific Writer, WriterSync, and Closer interfaces as well as provides a WritableStream interface.

Version related information.

Functions

Registers the given function as a listener of the given signal event.

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.

Synchronously change owner of a regular file or directory.

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)

f
Deno.copy
deprecated

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.FsFile.

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

Return a string representing the current working directory.

Returns the path to the current deno executable.

Exit the Deno process with optional exit code.

Flushes any pending data operations of the given file stream to disk.

Synchronously flushes any pending data operations of the given file stream to disk.

Returns a Deno.FileInfo for the given file stream.

Synchronously returns a Deno.FileInfo for the given file stream.

Flushes any pending data and metadata operations of the given file stream to disk.

Synchronously flushes any pending data and metadata operations of the given file stream to disk.

Truncates or extends the specified file stream, to reach the specified len.

Synchronously truncates or extends the specified file stream, to reach the specified len.

Get the hostname of the machine the Deno process is running on.

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 (a terminal).

f
Deno.iter
deprecated

Turns a Reader, r, into an async iterator.

f
Deno.iterSync
deprecated

Turns a ReaderSync, r, into an iterator.

Send a signal to process under given pid.

Creates newpath as a hard link to oldpath.

Synchronously creates newpath as a hard link to oldpath.

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, 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, 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, unless dir is specified.

Synchronously creates a new temporary file in the default directory for temporary files, unless dir is specified.

Returns an object describing the memory usage of the Deno process and the V8 subsystem measured in bytes.

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 sandbox and the rest of Deno.

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.FsFile. The file does not need to previously exist if using the create or createNew open options. It is the caller's responsibility to close the file when finished with it.

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

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

f
Deno.readAll
deprecated

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

f
Deno.readAllSync
deprecated

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.

Synchronously 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 an UTF-8 decoded string. Reading a directory throws an error.

Synchronously reads and returns the entire contents of a file as an UTF-8 decoded string. Reading a directory throws an error.

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

Synchronously returns absolute normalized path, with symbolic links resolved.

Make the timer of the given id block the event loop from finishing.

Removes the named file or directory.

Removes the given signal listener that has been registered with Deno.addSignalListener.

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 unknown type; that means it can change any time and should not be depended upon.

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.

Services HTTP requests given a TCP or TLS socket.

Shutdown socket send operations.

Start TLS handshake from an existing connection using an optional list of CA certificates, and hostname (default is "127.0.0.1"). Specifying CA certs is optional. By default the configured root certificates are used. Using this function requires that the other end of the connection is prepared for a TLS handshake.

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.

Creates newpath as a symbolic link to oldpath.

Creates newpath as a symbolic link to oldpath.

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.

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.

Make the timer of the given id not block the event loop from finishing.

Used to upgrade an incoming HTTP request to a WebSocket.

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).

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

f
Deno.writeAll
deprecated

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).

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.

Interfaces

If resolveDns is called with "CAA" record type specified, it will return an array of this interface.

An abstract interface which when implemented provides an interface to close files/resources that were previously opened.

Information about a directory entry returned from Deno.readDir and Deno.readDirSync.

An interface containing methods to interact with the process environment variables.

Provides information about a file and is returned by Deno.stat, Deno.lstat, Deno.statSync, and Deno.lstatSync or from calling stat() and statSync() on an Deno.FsFile instance.

Represents a unique file system event yielded by a Deno.FsWatcher.

Returned by Deno.watchFs. It is an async iterator yielding up system events. To stop watching the file system by calling .close() method.

Option which can be specified when performing Deno.inspect.

A generic network listener for stream-oriented protocols.

Options which can be set when using Deno.mkdir and Deno.mkdirSync.

If resolveDns is called with "MX" record type specified, it will return an array of this interface.

If resolveDns is called with "NAPTR" record type specified, it will return an array of this interface.

Options which can be set when doing Deno.open and Deno.openSync.

A set of options which can define the permissions within a test or worker context at a highly specific level.

An abstract interface which when implemented provides an interface to read bytes into an array buffer asynchronously.

An abstract interface which when implemented provides an interface to read bytes into an array buffer synchronously.

Options which can be set when using Deno.readFile or Deno.readFileSync.

Options which can be set when using Deno.remove and Deno.removeSync.

Options which can be used with Deno.run.

An abstract interface which when implemented provides an interface to seek within an open file/resource asynchronously.

An abstract interface which when implemented provides an interface to seek within an open file/resource synchronously.

UNSTABLE: new API, yet to be vetted.

If resolveDns is called with "SOA" record type specified, it will return an array of this interface.

If resolveDns is called with "SRV" record type specified, it will return an array of this interface.

Context that is passed to a testing function, which can be used to either gain information about the current test, or register additional test steps within the current test.

Specialized listener that accepts TLS connections.

Options for writing to a file.

An abstract interface which when implemented provides an interface to write bytes from an array buffer to a file/resource asynchronously.

An abstract interface which when implemented provides an interface to write bytes from an array buffer to a file/resource synchronously.

Type Aliases

Additional information for FsEvent objects with the "other" kind.

Permission descriptors which define a permission and can be queried, requested, or revoked.

The name of a privileged feature which needs permission.

Options which define the permissions within a test or worker context.

The current status of the permission:

The status resolved from the .status() method of a Deno.Process instance.

The type of the resource record. Only the listed types are supported currently.

Operating signals which can be listened for or sent to sub-processes. What signals and what their standard behaviors are are OS dependent.