Skip to main content

Deno APIs reference

Every API in the global Deno namespace, by category. Use your browser's find-in-page to locate a symbol, then click through for full documentation.

Bundle

Bundler

Cloud

Errors

  • c
    Deno.errors.AddrInUse

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

  • c
    Deno.errors.AddrNotAvailable

    Raised when the underlying operating system reports an EADDRNOTAVAIL error.

  • c
    Deno.errors.AlreadyExists

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

  • c
    Deno.errors.BadResource

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

  • c
    Deno.errors.BrokenPipe

    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.

  • c
    Deno.errors.Busy

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

  • c
    Deno.errors.ConnectionAborted

    Raised when the underlying operating system reports an ECONNABORTED error.

  • c
    Deno.errors.ConnectionRefused

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

  • c
    Deno.errors.ConnectionReset

    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.

  • c
    Deno.errors.FilesystemLoop

    Raised when too many symbolic links were encountered when resolving the filename.

  • c
    Deno.errors.Http

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

  • c
    Deno.errors.Interrupted

    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 BadResource error instead.

  • c
    Deno.errors.InvalidData

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

  • c
    Deno.errors.IsADirectory

    Raised when trying to open, create or write to a directory.

  • c
    Deno.errors.NetworkUnreachable

    Raised when performing a socket operation but the remote host is not reachable.

  • c
    Deno.errors.NotADirectory

    Raised when trying to perform an operation on a path that is not a directory, when directory is required.

  • c
    Deno.errors.NotCapable

    Raised when trying to perform an operation while the relevant Deno permission (like --allow-read) has not been granted.

  • c
    Deno.errors.NotConnected

    Raised when the underlying operating system reports an ENOTCONN error.

  • c
    Deno.errors.NotFound

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

  • c
    Deno.errors.NotSupported

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

  • c
    Deno.errors.PermissionDenied

    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.

  • c
    Deno.errors.TimedOut

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

  • c
    Deno.errors.UnexpectedEof

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

  • c
    Deno.errors.WouldBlock

    Raised when the underlying operating system would need to block to complete but an asynchronous (non-blocking) API is used.

  • c
    Deno.errors.WriteZero

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

  • N
    Deno.errors

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

Fetch

FFI

File System

  • c
    Deno.FsFile

    The Deno abstraction for reading and writing files.

  • f
    Deno.chmod

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

  • f
    Deno.chmodSync

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

  • f
    Deno.chown

    Change owner of a regular file or directory.

  • f
    Deno.chownSync

    Synchronously change owner of a regular file or directory.

  • f
    Deno.copyFile

    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.

  • f
    Deno.copyFileSync

    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.

  • f
    Deno.create

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

  • f
    Deno.createSync

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

  • f
    Deno.link

    Creates newpath as a hard link to oldpath.

  • f
    Deno.linkSync

    Synchronously creates newpath as a hard link to oldpath.

  • f
    Deno.lstat

    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.

  • f
    Deno.lstatSync

    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.

  • f
    Deno.makeTempDir

    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.

  • f
    Deno.makeTempDirSync

    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.

  • f
    Deno.makeTempFile

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

  • f
    Deno.makeTempFileSync

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

  • f
    Deno.mkdir

    Creates a new directory with the specified path.

  • f
    Deno.mkdirSync

    Synchronously creates a new directory with the specified path.

  • f
    Deno.open

    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. The caller may have the resulting file automatically closed by the runtime once it's out of scope by declaring the file variable with the using keyword.

  • f
    Deno.openSync

    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. The caller may have the resulting file automatically closed by the runtime once it's out of scope by declaring the file variable with the using keyword.

  • f
    Deno.readDir

    Reads the directory given by path and returns an async iterable of Deno.DirEntry. The order of entries is not guaranteed.

  • f
    Deno.readDirSync

    Synchronously reads the directory given by path and returns an iterable of Deno.DirEntry. The order of entries is not guaranteed.

  • f
    Deno.readFile

    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. Rejects with an error when reading a directory.

  • f
    Deno.readFileSync

    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. Throws an error when reading a directory.

  • f
    Deno.readLink

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

  • f
    Deno.readLinkSync

    Synchronously returns the full path destination of the named symbolic link.

  • f
    Deno.readTextFile

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

  • f
    Deno.readTextFileSync

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

  • f
    Deno.realPath

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

  • f
    Deno.realPathSync

    Synchronously returns absolute normalized path, with symbolic links resolved.

  • f
    Deno.remove

    Removes the named file or directory.

  • f
    Deno.removeSync

    Synchronously removes the named file or directory.

  • f
    Deno.rename

    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.

  • f
    Deno.renameSync

    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.

  • f
    Deno.stat

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

  • f
    Deno.statSync

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

  • f
    Deno.symlink

    Creates newpath as a symbolic link to oldpath.

  • f
    Deno.symlinkSync

    Creates newpath as a symbolic link to oldpath.

  • f
    Deno.truncate

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

  • f
    Deno.truncateSync

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

  • f
    Deno.umask

    Retrieve the process umask. If mask is provided, sets the process umask. This call always returns what the umask was before the call.

  • f
    Deno.utime

    Changes the access (atime) and modification (mtime) times of a file system object referenced by path. Given times are either in seconds (UNIX epoch time) or as Date objects.

  • f
    Deno.utimeSync

    Synchronously changes the access (atime) and modification (mtime) times of a file system object referenced by path. Given times are either in seconds (UNIX epoch time) or as Date objects.

  • f
    Deno.watchFs

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

  • f
    Deno.writeFile

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

  • f
    Deno.writeFileSync

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

  • f
    Deno.writeTextFile

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

  • f
    Deno.writeTextFileSync

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

  • I
    Deno.DirEntry

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

  • I
    Deno.FileInfo

    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.

  • I
    Deno.FsEvent

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

  • I
    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.

  • I
    Deno.MakeTempOptions
  • I
    Deno.MkdirOptions

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

  • I
    Deno.OpenOptions

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

  • I
    Deno.ReadFileOptions

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

  • I
    Deno.RemoveOptions

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

  • I
    Deno.SymlinkOptions

    Options that can be used with symlink and symlinkSync.

  • I
    Deno.WriteFileOptions

    Options for writing to a file.

  • T
    Deno.FsEventFlag

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

GPU

HTTP Server

I/O

  • E
    Deno.SeekMode

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

  • f
    Deno.consoleSize

    Gets the size of the console as columns/rows.

  • f
    Deno.inspect

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

  • I
    Deno.InspectOptions

    Option which can be specified when performing Deno.inspect.

  • I
    Deno.SetRawOptions
  • v
    Deno.stderr

    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.

  • v
    Deno.stdin

    A reference to stdin which can be used to read directly from stdin.

  • v
    Deno.stdout

    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.

Jupyter

Linter

Network

Permissions

  • c
    Deno.Permissions

    Deno's permission management API.

  • c
    Deno.PermissionStatus

    An EventTarget returned from the Deno.permissions API which can provide updates to any state changes of the permission.

  • I
    Deno.EnvPermissionDescriptor

    The permission descriptor for the allow-env and deny-env permissions, which controls access to being able to read and write to the process environment variables as well as access other information about the environment. The option variable allows scoping the permission to a specific environment variable.

  • I
    Deno.FfiPermissionDescriptor

    The permission descriptor for the allow-ffi and deny-ffi permissions, which controls access to loading foreign code and interfacing with it via the Foreign Function Interface API available in Deno. The option path allows scoping the permission to a specific path on the host.

  • I
    Deno.ImportPermissionDescriptor

    The permission descriptor for the allow-import and deny-import permissions, which controls access to importing from remote hosts via the network. The option host allows scoping the permission for outbound connection to a specific host and port.

  • I
    Deno.NetPermissionDescriptor

    The permission descriptor for the allow-net and deny-net permissions, which controls access to opening network ports and connecting to remote hosts via the network. The option host allows scoping the permission for outbound connection to a specific host and port.

  • I
    Deno.PermissionOptionsObject

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

  • I
    Deno.PermissionStatusEventMap

    The interface which defines what event types are supported by PermissionStatus instances.

  • I
    Deno.ReadPermissionDescriptor

    The permission descriptor for the allow-read and deny-read permissions, which controls access to reading resources from the local host. The option path allows scoping the permission to a specific path (and if the path is a directory any sub paths).

  • I
    Deno.RunPermissionDescriptor

    The permission descriptor for the allow-run and deny-run permissions, which controls access to what sub-processes can be executed by Deno. The option command allows scoping the permission to a specific executable.

  • I
    Deno.SysPermissionDescriptor

    The permission descriptor for the allow-sys and deny-sys permissions, which controls access to sensitive host system information, which malicious code might attempt to exploit. The option kind allows scoping the permission to a specific piece of information.

  • I
    Deno.WritePermissionDescriptor

    The permission descriptor for the allow-write and deny-write permissions, which controls access to writing to resources from the local host. The option path allow scoping the permission to a specific path (and if the path is a directory any sub paths).

  • T
    Deno.PermissionDescriptor

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

  • T
    Deno.PermissionName

    The name of a privileged feature which needs permission.

  • T
    Deno.PermissionOptions

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

  • T
    Deno.PermissionState

    The current status of the permission:

  • v
    Deno.permissions

    Deno's permission management API.

Runtime

  • f
    Deno.addSignalListener

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

  • f
    Deno.chdir

    Change the current working directory to the specified path.

  • f
    Deno.cwd

    Return a string representing the current working directory.

  • f
    Deno.execPath

    Returns the path to the current deno executable.

  • f
    Deno.exit

    Exit the Deno process with optional exit code.

  • f
    Deno.gid

    Returns the group id of the process on POSIX platforms. Returns null on windows.

  • f
    Deno.hostname

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

  • f
    Deno.loadavg

    Returns an array containing the 1, 5, and 15 minute load averages. The load average is a measure of CPU and IO utilization of the last one, five, and 15 minute periods expressed as a fractional number. Zero means there is no load. On Windows, the three values are always the same and represent the current load, not the 1, 5 and 15 minute load averages.

  • f
    Deno.memoryUsage

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

  • f
    Deno.osRelease

    Returns the release version of the Operating System.

  • f
    Deno.osUptime

    Returns the Operating System uptime in number of seconds.

  • f
    Deno.refTimer

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

  • f
    Deno.removeSignalListener

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

  • f
    Deno.systemMemoryInfo

    Displays the total amount of free and used physical and swap memory in the system, as well as the buffers and caches used by the kernel.

  • f
    Deno.uid

    Returns the user id of the process on POSIX platforms. Returns null on Windows.

  • f
    Deno.unrefTimer

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

  • I
    Deno.Env

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

  • I
    Deno.MemoryUsage
  • I
    Deno.SystemMemoryInfo

    Information returned from a call to Deno.systemMemoryInfo.

  • T
    Deno.Signal

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

  • v
    Deno.args

    Returns the script arguments to the program.

  • v
    Deno.build

    Information related to the build of the current Deno runtime.

  • v
    Deno.env

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

  • v
    Deno.exitCode

    The exit code for the Deno process.

  • v
    Deno.mainModule

    The URL of the entrypoint module entered from the command-line. It requires read permission to the CWD.

  • v
    Deno.noColor

    Reflects the NO_COLOR environment variable at program start.

  • v
    Deno.pid

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

  • v
    Deno.ppid

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

  • v
    Deno.version

    Version information related to the current Deno CLI runtime environment.

Subprocess

Telemetry

Testing

  • f
    Deno.bench

    Register a benchmark test which will be run when deno bench is used on the command line and the containing module looks like a bench module.

  • I
    Deno.BenchContext

    Context that is passed to a benchmarked function. The instance is shared between iterations of the benchmark. Its methods can be used for example to override of the measured portion of the function.

  • I
    Deno.BenchDefinition

    The interface for defining a benchmark test using Deno.bench.

  • I
    Deno.DenoTest
  • I
    Deno.TestContext

    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.

  • I
    Deno.TestDefinition
  • I
    Deno.TestStepDefinition
  • v
    Deno.test

    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.

WebSockets

Other APIs

  • N
    Deno

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

Did you find what you needed?

Privacy policy