Skip to main content
All Symbols - Deno documentation

default

The global namespace where Deno specific, non-standard APIs are located.
N
Deno
The global namespace where Deno specific, non-standard APIs are located.
T
Deno.Addr
No documentation available
f
Deno.addSignalListener
Registers the given function as a listener of the given signal event. ```ts Deno.addSignalListener( "SIGTERM", () => { console.log("SIGTERM!") } ); ``` _Note_: On Windows only `"SIGINT"` (CTRL+C) and `"SIGBREAK"` (CTRL+Break) are supported.
v
Deno.args
Returns the script arguments to the program. Give the following command line invocation of Deno: ```sh deno run --allow-read https://examples.deno.land/command-line-arguments.ts Sushi ``` Then `Deno.args` will contain: ```ts [ "Sushi" ] ``` If you are looking for a structured way to parse arguments, there is [`parseArgs()`](https://jsr.io/@std/cli/doc/parse-args/~/parseArgs) from the Deno Standard Library.
I
Deno.AtomicCheck
A check to perform as part of a [`Deno.AtomicOperation`](./././~/Deno.AtomicOperation). The check will fail if the versionstamp for the key-value pair in the KV store does not match the given versionstamp. A check with a `null` versionstamp checks that the key-value pair does not currently exist in the KV store.
c
Deno.AtomicOperation
An operation on a [`Deno.Kv`](./././~/Deno.Kv) that can be performed atomically. Atomic operations do not auto-commit, and must be committed explicitly by calling the `commit` method. Atomic operations can be used to perform multiple mutations on the KV store in a single atomic transaction. They can also be used to perform conditional mutations by specifying one or more [`Deno.AtomicCheck`](./././~/Deno.AtomicCheck)s that ensure that a mutation is only performed if the key-value pair in the KV has a specific versionstamp. If any of the checks fail, the entire operation will fail and no mutations will be made. The ordering of mutations is guaranteed to be the same as the ordering of the mutations specified in the operation. Checks are performed before any mutations are performed. The ordering of checks is unobservable. Atomic operations can be used to implement optimistic locking, where a mutation is only performed if the key-value pair in the KV store has not been modified since the last read. This can be done by specifying a check that ensures that the versionstamp of the key-value pair matches the versionstamp that was read. If the check fails, the mutation will not be performed and the operation will fail. One can then retry the read-modify- write operation in a loop until it succeeds. The `commit` method of an atomic operation returns a value indicating whether checks passed and mutations were performed. If the operation failed because of a failed check, the return value will be a [`Deno.KvCommitError`](./././~/Deno.KvCommitError) with an `ok: false` property. If the operation failed for any other reason (storage error, invalid value, etc.), an exception will be thrown. If the operation succeeded, the return value will be a [`Deno.KvCommitResult`](./././~/Deno.KvCommitResult) object with a `ok: true` property and the versionstamp of the value committed to KV.
I
Deno.BasicAuth
Basic authentication credentials to be used with a [`Deno.Proxy`](./././~/Deno.Proxy) server when specifying [`Deno.CreateHttpClientOptions`](./././~/Deno.CreateHttpClientOptions).
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. If the test function (`fn`) returns a promise or is async, the test runner will await resolution to consider the test complete. ```ts import { assertEquals } from "jsr:@std/assert"; Deno.bench({ name: "example test", fn() { assertEquals("world", "world"); }, }); Deno.bench({ name: "example ignored test", ignore: Deno.build.os === "windows", fn() { // This test is ignored only on Windows machines }, }); Deno.bench({ name: "example async test", async fn() { const decoder = new TextDecoder("utf-8"); const data = await Deno.readFile("hello_world.txt"); assertEquals(decoder.decode(data), "Hello world"); } }); ```
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`](./././~/Deno.bench).
v
Deno.brand
No documentation available
v
Deno.build
Information related to the build of the current Deno runtime. Users are discouraged from code branching based on this information, as assumptions about what is available in what build environment might change over time. Developers should specifically sniff out the features they intend to use. The intended use for the information is for logging and debugging purposes.
I
Deno.CaaRecord
If [`Deno.resolveDns`](./././~/Deno.resolveDns) is called with `"CAA"` record type specified, it will resolve with an array of objects with this interface.
f
Deno.chdir
Change the current working directory to the specified path. ```ts Deno.chdir("/home/userA"); Deno.chdir("../userB"); Deno.chdir("C:\\Program Files (x86)\\Java"); ``` Throws [`Deno.errors.NotFound`](./././~/Deno.errors.NotFound) if directory not found. Throws [`Deno.errors.PermissionDenied`](./././~/Deno.errors.PermissionDenied) if the user does not have operating system file access rights. Requires `allow-read` permission.
c
Deno.ChildProcess
The interface for handling a child process returned from `Deno.Command.spawn`.
f
Deno.chmod
Changes the permission of a specific file/directory of specified path. Ignores the process's umask. ```ts await Deno.chmod("/path/to/file", 0o666); ``` The mode is a sequence of 3 octal numbers. The first/left-most number specifies the permissions for the owner. The second number specifies the permissions for the group. The last/right-most number specifies the permissions for others. For example, with a mode of 0o764, the owner (7) can read/write/execute, the group (6) can read/write and everyone else (4) can read only. | Number | Description | | ------ | ----------- | | 7 | read, write, and execute | | 6 | read and write | | 5 | read and execute | | 4 | read only | | 3 | write and execute | | 2 | write only | | 1 | execute only | | 0 | no permission | NOTE: This API currently throws on Windows Requires `allow-write` permission.
f
Deno.chmodSync
Synchronously changes the permission of a specific file/directory of specified path. Ignores the process's umask. ```ts Deno.chmodSync("/path/to/file", 0o666); ``` For a full description, see [`Deno.chmod`](./././~/Deno.chmod). NOTE: This API currently throws on Windows Requires `allow-write` permission.
f
Deno.chown
Change owner of a regular file or directory. This functionality is not available on Windows. ```ts await Deno.chown("myFile.txt", 1000, 1002); ``` Requires `allow-write` permission. Throws Error (not implemented) if executed on Windows.
f
Deno.chownSync
Synchronously change owner of a regular file or directory. This functionality is not available on Windows. ```ts Deno.chownSync("myFile.txt", 1000, 1002); ``` Requires `allow-write` permission. Throws Error (not implemented) if executed on Windows.
c
Deno.Command
Create a child process. If any stdio options are not set to `"piped"`, accessing the corresponding field on the `Command` or its `CommandOutput` will throw a `TypeError`. If `stdin` is set to `"piped"`, the `stdin` `WritableStream` needs to be closed manually. `Command` acts as a builder. Each call to `Command.spawn` or `Command.output` will spawn a new subprocess.
I
Deno.CommandOptions
Options which can be set when calling [`Deno.Command`](./././~/Deno.Command).
I
Deno.CommandOutput
The interface returned from calling `Deno.Command.output` or `Deno.Command.outputSync` which represents the result of spawning the child process.
I
Deno.CommandStatus
No documentation available
T
Deno.ConditionalAsync
No documentation available
f
Deno.connect
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`). ```ts const conn1 = await Deno.connect({ port: 80 }); const conn2 = await Deno.connect({ hostname: "192.0.2.1", port: 80 }); const conn3 = await Deno.connect({ hostname: "[2001:db8::1]", port: 80 }); const conn4 = await Deno.connect({ hostname: "golang.org", port: 80, transport: "tcp" }); ``` Requires `allow-net` permission for "tcp".
I
Deno.ConnectOptions
No documentation available
f
Deno.connectTls
Establishes a secure connection over TLS (transport layer security) using an optional list of CA certs, hostname (default is "127.0.0.1") and port. The CA cert list is optional and if not included Mozilla's root certificates will be used (see also https://github.com/ctz/webpki-roots for specifics). Mutual TLS (mTLS or client certificates) are supported by providing a `key` and `cert` in the options as PEM-encoded strings. ```ts const caCert = await Deno.readTextFile("./certs/my_custom_root_CA.pem"); const conn1 = await Deno.connectTls({ port: 80 }); const conn2 = await Deno.connectTls({ caCerts: [caCert], hostname: "192.0.2.1", port: 80 }); const conn3 = await Deno.connectTls({ hostname: "[2001:db8::1]", port: 80 }); const conn4 = await Deno.connectTls({ caCerts: [caCert], hostname: "golang.org", port: 80}); const key = "----BEGIN PRIVATE KEY----..."; const cert = "----BEGIN CERTIFICATE----..."; const conn5 = await Deno.connectTls({ port: 80, key, cert }); ``` Requires `allow-net` permission.
f
Deno.consoleSize
Gets the size of the console as columns/rows. ```ts const { columns, rows } = Deno.consoleSize(); ``` This returns the size of the console window as reported by the operating system. It's not a reflection of how many characters will fit within the console window, but can be used as part of that calculation.
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. ```ts await Deno.copyFile("from.txt", "to.txt"); ``` Requires `allow-read` permission on `fromPath`. Requires `allow-write` permission on `toPath`.
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. ```ts Deno.copyFileSync("from.txt", "to.txt"); ``` Requires `allow-read` permission on `fromPath`. Requires `allow-write` permission on `toPath`.
f
Deno.create
Creates a file if none exists or truncates an existing file and resolves to an instance of [`Deno.FsFile`](./././~/Deno.FsFile). ```ts const file = await Deno.create("/foo/bar.txt"); ``` Requires `allow-read` and `allow-write` permissions.
f
Deno.createHttpClient
Create a custom HttpClient to use with `fetch`. This is an extension of the web platform Fetch API which allows Deno to use custom TLS CA certificates and connect via a proxy while using `fetch()`. The `cert` and `key` options can be used to specify a client certificate and key to use when connecting to a server that requires client authentication (mutual TLS or mTLS). The `cert` and `key` options must be provided in PEM format.
I
Deno.CreateHttpClientOptions
The options used when creating a [`Deno.HttpClient`](./././~/Deno.HttpClient).
f
Deno.createSync
Creates a file if none exists or truncates an existing file and returns an instance of [`Deno.FsFile`](./././~/Deno.FsFile). ```ts const file = Deno.createSync("/foo/bar.txt"); ``` Requires `allow-read` and `allow-write` permissions.
f
Deno.cron
Create a cron job that will periodically execute the provided handler callback based on the specified schedule. ```ts Deno.cron("sample cron", "20 * * * *", () => { console.log("cron job executed"); }); ``` ```ts Deno.cron("sample cron", { hour: { every: 6 } }, () => { console.log("cron job executed"); }); ``` `schedule` can be a string in the Unix cron format or in JSON format as specified by interface `CronSchedule`, where time is specified using UTC time zone.
I
Deno.CronSchedule
CronSchedule is the interface used for JSON format cron `schedule`.
T
Deno.CronScheduleExpression
CronScheduleExpression is used as the type of `minute`, `hour`, `dayOfMonth`, `month`, and `dayOfWeek` in `CronSchedule`.
f
Deno.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. ```ts const currentWorkingDirectory = Deno.cwd(); ``` Throws [`Deno.errors.NotFound`](./././~/Deno.errors.NotFound) if directory not available. Requires `allow-read` permission.
I
Deno.DatagramConn
A generic transport listener for message-oriented protocols.
I
Deno.DenoTest
No documentation available
I
Deno.DirEntry
Information about a directory entry returned from [`Deno.readDir`](./././~/Deno.readDir) and [`Deno.readDirSync`](./././~/Deno.readDirSync).
f
Deno.dlopen
Opens an external dynamic library and registers symbols, making foreign functions available to be called. Requires `allow-ffi` permission. Loading foreign dynamic libraries can in theory bypass all of the sandbox permissions. While it is a separate permission users should acknowledge in practice that is effectively the same as running with the `allow-all` permission.
I
Deno.DynamicLibrary
A dynamic library resource. Use [`Deno.dlopen`](./././~/Deno.dlopen) to load a dynamic library and return this interface.
I
Deno.Env
An interface containing methods to interact with the process environment variables.
v
Deno.env
An interface containing methods to interact with the process environment variables.
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.
N
Deno.errors
A set of error constructors that are raised by Deno APIs. Can be used to provide more specific handling of failures within code which is using Deno APIs. For example, handling attempting to open a file which does not exist: ```ts try { const file = await Deno.open("./some/file.txt"); } catch (error) { if (error instanceof Deno.errors.NotFound) { console.error("the file was not found"); } else { // otherwise re-throw throw error; } } ```
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 @{link BadResource} error instead.
c
Deno.errors.InvalidData
Raised when an operation to 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. Before Deno 2.0, this condition was covered by the PermissionDenied error.
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. Before Deno 2.0, this error was raised when the user _did not_ provide required `--allow-*` flag. As of Deno 2.0, that case is now handled by the NotCapable error.
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.
f
Deno.execPath
Returns the path to the current deno executable. ```ts console.log(Deno.execPath()); // e.g. "/home/alice/.local/bin/deno" ``` Requires `allow-read` permission.
f
Deno.exit
Exit the Deno process with optional exit code. If no exit code is supplied then Deno will exit with return code of `0`. In worker contexts this is an alias to `self.close();`. ```ts Deno.exit(5); ```
v
Deno.exitCode
The exit code for the Deno process. If no exit code has been supplied, then Deno will assume a return code of `0`. When setting an exit code value, a number or non-NaN string must be provided, otherwise a TypeError will be thrown. ```ts console.log(Deno.exitCode); //-> 0 Deno.exitCode = 1; console.log(Deno.exitCode); //-> 1 ```
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](https://docs.deno.com/runtime/manual/runtime/ffi_api) available in Deno. The option `path` allows scoping the permission to a specific path on the host.
I
Deno.FileInfo
Provides information about a file and is returned by [`Deno.stat`](./././~/Deno.stat), [`Deno.lstat`](./././~/Deno.lstat), [`Deno.statSync`](./././~/Deno.statSync), and [`Deno.lstatSync`](./././~/Deno.lstatSync) or from calling `stat()` and `statSync()` on an [`Deno.FsFile`](./././~/Deno.FsFile) instance.
I
Deno.ForeignFunction
The interface for a foreign function as defined by its parameter and result types.
I
Deno.ForeignLibraryInterface
A foreign library interface descriptor.
I
Deno.ForeignStatic
No documentation available
T
Deno.FromForeignFunction
No documentation available
T
Deno.FromNativeParameterTypes
No documentation available
T
Deno.FromNativeResultType
Type conversion for foreign symbol return types.
T
Deno.FromNativeType
Type conversion for foreign symbol return types and unsafe callback parameters.
I
Deno.FsEvent
Represents a unique file system event yielded by a [`Deno.FsWatcher`](./././~/Deno.FsWatcher).
T
Deno.FsEventFlag
Additional information for FsEvent objects with the "other" kind. - `"rescan"`: rescan notices indicate either a lapse in the events or a change in the filesystem such that events received so far can no longer be relied on to represent the state of the filesystem now. An application that simply reacts to file changes may not care about this. An application that keeps an in-memory representation of the filesystem will need to care, and will need to refresh that representation directly from the filesystem.
c
Deno.FsFile
The Deno abstraction for reading and writing files. This is the most straight forward way of handling files within Deno and is recommended over using the discrete functions within the `Deno` namespace. ```ts using file = await Deno.open("/foo/bar.txt", { read: true }); const fileInfo = await file.stat(); if (fileInfo.isFile) { const buf = new Uint8Array(100); const numberOfBytesRead = await file.read(buf); // 11 bytes const text = new TextDecoder().decode(buf); // "hello world" } ```
I
Deno.FsWatcher
Returned by [`Deno.watchFs`](./././~/Deno.watchFs). It is an async iterator yielding up system events. To stop watching the file system by calling `.close()` method.
f
Deno.gid
Returns the group id of the process on POSIX platforms. Returns null on windows. ```ts console.log(Deno.gid()); ``` Requires `allow-sys` permission.
f
Deno.hostname
Get the `hostname` of the machine the Deno process is running on. ```ts console.log(Deno.hostname()); ``` Requires `allow-sys` permission.
c
Deno.HttpClient
A custom `HttpClient` for use with `fetch` function. This is designed to allow custom certificates or proxies to be used with `fetch()`.
I
Deno.HttpServer
An instance of the server created using `Deno.serve()` API.
f
Deno.inspect
Converts the input into a string that has the same format as printed by `console.log()`. ```ts const obj = { a: 10, b: "hello", }; const objAsString = Deno.inspect(obj); // { a: 10, b: "hello" } console.log(obj); // prints same value as objAsString, e.g. { a: 10, b: "hello" } ``` A custom inspect functions can be registered on objects, via the symbol `Symbol.for("Deno.customInspect")`, to control and customize the output of `inspect()` or when using `console` logging: ```ts class A { x = 10; y = "hello"; [Symbol.for("Deno.customInspect")]() { return `x=${this.x}, y=${this.y}`; } } const inStringFormat = Deno.inspect(new A()); // "x=10, y=hello" console.log(inStringFormat); // prints "x=10, y=hello" ``` A depth can be specified by using the `depth` option: ```ts Deno.inspect({a: {b: {c: {d: 'hello'}}}}, {depth: 2}); // { a: { b: [Object] } } ```
N
Deno.jupyter
A namespace containing runtime APIs available in Jupyter notebooks. When accessed outside of Jupyter notebook context an error will be thrown.
v
Deno.jupyter.$display
No documentation available
f
Deno.jupyter.broadcast
Broadcast a message on IO pub channel. ``` await Deno.jupyter.broadcast("display_data", { data: { "text/html": "Processing." }, metadata: {}, transient: { display_id: "progress" } }); await new Promise((resolve) => setTimeout(resolve, 500)); await Deno.jupyter.broadcast("update_display_data", { data: { "text/html": "Processing.." }, metadata: {}, transient: { display_id: "progress" } }); ```
f
Deno.jupyter.display
Display function for Jupyter Deno Kernel. Mimics the behavior of IPython's `display(obj, raw=True)` function to allow asynchronous displaying of objects in Jupyter.
I
Deno.jupyter.Displayable
No documentation available
f
Deno.jupyter.format
Format an object for displaying in Deno
f
Deno.jupyter.html
Show HTML in Jupyter frontends with a tagged template function. Takes a template string and returns a displayable object for Jupyter frontends.
f
Deno.jupyter.md
Show Markdown in Jupyter frontends with a tagged template function. Takes a template string and returns a displayable object for Jupyter frontends.
f
Deno.jupyter.svg
SVG Tagged Template Function. Takes a template string and returns a displayable object for Jupyter frontends. Example usage: svg` `
I
Deno.jupyter.VegaObject
No documentation available
f
Deno.kill
Send a signal to process under given `pid`. The value and meaning of the `signal` to the process is operating system and process dependant. `Signal` provides the most common signals. Default signal is `"SIGTERM"`. The term `kill` is adopted from the UNIX-like command line command `kill` which also signals processes. If `pid` is negative, the signal will be sent to the process group identified by `pid`. An error will be thrown if a negative `pid` is used on Windows. ```ts const command = new Deno.Command("sleep", { args: ["10000"] }); const child = command.spawn(); Deno.kill(child.pid, "SIGINT"); ``` Requires `allow-run` permission.
c
Deno.Kv
A key-value database that can be used to store and retrieve data. Data is stored as key-value pairs, where the key is a [`Deno.KvKey`](./././~/Deno.KvKey) and the value is an arbitrary structured-serializable JavaScript value. Keys are ordered lexicographically as described in the documentation for [`Deno.KvKey`](./././~/Deno.KvKey). Keys are unique within a database, and the last value set for a given key is the one that is returned when reading the key. Keys can be deleted from the database, in which case they will no longer be returned when reading keys. Values can be any structured-serializable JavaScript value (objects, arrays, strings, numbers, etc.). The special value [`Deno.KvU64`](./././~/Deno.KvU64) can be used to store 64-bit unsigned integers in the database. This special value can not be nested within other objects or arrays. In addition to the regular database mutation operations, the unsigned 64-bit integer value also supports `sum`, `max`, and `min` mutations. Keys are versioned on write by assigning the key an ever-increasing "versionstamp". The versionstamp represents the version of a key-value pair in the database at some point in time, and can be used to perform transactional operations on the database without requiring any locking. This is enabled by atomic operations, which can have conditions that ensure that the operation only succeeds if the versionstamp of the key-value pair matches an expected versionstamp. Keys have a maximum length of 2048 bytes after serialization. Values have a maximum length of 64 KiB after serialization. Serialization of both keys and values is somewhat opaque, but one can usually assume that the serialization of any value is about the same length as the resulting string of a JSON serialization of that same value. If theses limits are exceeded, an exception will be thrown.
I
Deno.KvCommitError
No documentation available
I
Deno.KvCommitResult
No documentation available
T
Deno.KvConsistencyLevel
Consistency level of a KV operation. - `strong` - This operation must be strongly-consistent. - `eventual` - Eventually-consistent behavior is allowed.
I
Deno.KvEntry
A versioned pair of key and value in a [`Deno.Kv`](./././~/Deno.Kv). The `versionstamp` is a string that represents the current version of the key-value pair. It can be used to perform atomic operations on the KV store by passing it to the `check` method of a [`Deno.AtomicOperation`](./././~/Deno.AtomicOperation).
T
Deno.KvEntryMaybe
An optional versioned pair of key and value in a [`Deno.Kv`](./././~/Deno.Kv). This is the same as a `KvEntry`, but the `value` and `versionstamp` fields may be `null` if no value exists for the given key in the KV store.
T
Deno.KvKey
A key to be persisted in a [`Deno.Kv`](./././~/Deno.Kv). A key is a sequence of [`Deno.KvKeyPart`](./././~/Deno.KvKeyPart)s. Keys are ordered lexicographically by their parts. The first part is the most significant, and the last part is the least significant. The order of the parts is determined by both the type and the value of the part. The relative significance of the types can be found in documentation for the [`Deno.KvKeyPart`](./././~/Deno.KvKeyPart) type. Keys have a maximum size of 2048 bytes serialized. If the size of the key exceeds this limit, an error will be thrown on the operation that this key was passed to.
T
Deno.KvKeyPart
A single part of a [`Deno.KvKey`](./././~/Deno.KvKey). Parts are ordered lexicographically, first by their type, and within a given type by their value. The ordering of types is as follows: 1. `Uint8Array` 2. `string` 3. `number` 4. `bigint` 5. `boolean` Within a given type, the ordering is as follows: - `Uint8Array` is ordered by the byte ordering of the array - `string` is ordered by the byte ordering of the UTF-8 encoding of the string - `number` is ordered following this pattern: `-NaN` < `-Infinity` < `-100.0` < `-1.0` < -`0.5` < `-0.0` < `0.0` < `0.5` < `1.0` < `100.0` < `Infinity` < `NaN` - `bigint` is ordered by mathematical ordering, with the largest negative number being the least first value, and the largest positive number being the last value - `boolean` is ordered by `false` < `true` This means that the part `1.0` (a number) is ordered before the part `2.0` (also a number), but is greater than the part `0n` (a bigint), because `1.0` is a number and `0n` is a bigint, and type ordering has precedence over the ordering of values within a type.
c
Deno.KvListIterator
An iterator over a range of data entries in a [`Deno.Kv`](./././~/Deno.Kv). The cursor getter returns the cursor that can be used to resume the iteration from the current position in the future.
I
Deno.KvListOptions
Options for listing key-value pairs in a [`Deno.Kv`](./././~/Deno.Kv).
T
Deno.KvListSelector
A selector that selects the range of data returned by a list operation on a [`Deno.Kv`](./././~/Deno.Kv). The selector can either be a prefix selector or a range selector. A prefix selector selects all keys that start with the given prefix (optionally starting at a given key). A range selector selects all keys that are lexicographically between the given start and end keys.
T
Deno.KvMutation
A mutation to a key in a [`Deno.Kv`](./././~/Deno.Kv). A mutation is a combination of a key, a value, and a type. The type determines how the mutation is applied to the key. - `set` - Sets the value of the key to the given value, overwriting any existing value. Optionally an `expireIn` option can be specified to set a time-to-live (TTL) for the key. The TTL is specified in milliseconds, and the key will be deleted from the database at earliest after the specified number of milliseconds have elapsed. Once the specified duration has passed, the key may still be visible for some additional time. If the `expireIn` option is not specified, the key will not expire. - `delete` - Deletes the key from the database. The mutation is a no-op if the key does not exist. - `sum` - Adds the given value to the existing value of the key. Both the value specified in the mutation, and any existing value must be of type `Deno.KvU64`. If the key does not exist, the value is set to the given value (summed with 0). If the result of the sum overflows an unsigned 64-bit integer, the result is wrapped around. - `max` - Sets the value of the key to the maximum of the existing value and the given value. Both the value specified in the mutation, and any existing value must be of type `Deno.KvU64`. If the key does not exist, the value is set to the given value. - `min` - Sets the value of the key to the minimum of the existing value and the given value. Both the value specified in the mutation, and any existing value must be of type `Deno.KvU64`. If the key does not exist, the value is set to the given value.
c
Deno.KvU64
Wrapper type for 64-bit unsigned integers for use as values in a [`Deno.Kv`](./././~/Deno.Kv).
f
Deno.linkSync
Synchronously creates `newpath` as a hard link to `oldpath`. ```ts Deno.linkSync("old/name", "new/name"); ``` Requires `allow-read` and `allow-write` permissions.
f
Deno.listen
Listen announces on the local transport address. ```ts const listener1 = Deno.listen({ port: 80 }) const listener2 = Deno.listen({ hostname: "192.0.2.1", port: 80 }) const listener3 = Deno.listen({ hostname: "[2001:db8::1]", port: 80 }); const listener4 = Deno.listen({ hostname: "golang.org", port: 80, transport: "tcp" }); ``` Requires `allow-net` permission.
f
Deno.listenDatagram
Listen announces on the local transport address. ```ts const listener1 = Deno.listenDatagram({ port: 80, transport: "udp" }); const listener2 = Deno.listenDatagram({ hostname: "golang.org", port: 80, transport: "udp" }); ``` Requires `allow-net` permission.
I
Deno.Listener
A generic network listener for stream-oriented protocols.
I
Deno.ListenOptions
No documentation available
f
Deno.listenTls
Listen announces on the local transport address over TLS (transport layer security). ```ts using listener = Deno.listenTls({ port: 443, cert: Deno.readTextFileSync("./server.crt"), key: Deno.readTextFileSync("./server.key"), }); ``` Requires `allow-net` permission.
I
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. ```ts console.log(Deno.loadavg()); // e.g. [ 0.71, 0.44, 0.44 ] ``` Requires `allow-sys` permission. On Windows there is no API available to retrieve this information and this method returns `[ 0, 0, 0 ]`.
f
Deno.lstat
Resolves to a [`Deno.FileInfo`](./././~/Deno.FileInfo) for the specified `path`. If `path` is a symlink, information for the symlink will be returned instead of what it points to. ```ts import { assert } from "jsr:@std/assert"; const fileInfo = await Deno.lstat("hello.txt"); assert(fileInfo.isFile); ``` Requires `allow-read` permission.
f
Deno.lstatSync
Synchronously returns a [`Deno.FileInfo`](./././~/Deno.FileInfo) for the specified `path`. If `path` is a symlink, information for the symlink will be returned instead of what it points to. ```ts import { assert } from "jsr:@std/assert"; const fileInfo = Deno.lstatSync("hello.txt"); assert(fileInfo.isFile); ``` Requires `allow-read` permission.
v
Deno.mainModule
The URL of the entrypoint module entered from the command-line. It requires read permission to the CWD. Also see `ImportMeta` for other related information.
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. This call resolves to the full path to the newly created directory. Multiple programs calling this function simultaneously will create different directories. It is the caller's responsibility to remove the directory when no longer needed. ```ts const tempDirName0 = await Deno.makeTempDir(); // e.g. /tmp/2894ea76 const tempDirName1 = await Deno.makeTempDir({ prefix: 'my_temp' }); // e.g. /tmp/my_temp339c944d ``` Requires `allow-write` permission.
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. The full path to the newly created directory is returned. Multiple programs calling this function simultaneously will create different directories. It is the caller's responsibility to remove the directory when no longer needed. ```ts const tempDirName0 = Deno.makeTempDirSync(); // e.g. /tmp/2894ea76 const tempDirName1 = Deno.makeTempDirSync({ prefix: 'my_temp' }); // e.g. /tmp/my_temp339c944d ``` Requires `allow-write` permission.
f
Deno.makeTempFile
Creates a new temporary file in the default directory for temporary files, unless `dir` is specified. Other options include prefixing and suffixing the directory name with `prefix` and `suffix` respectively. This call resolves to the full path to the newly created file. Multiple programs calling this function simultaneously will create different files. It is the caller's responsibility to remove the file when no longer needed. ```ts const tmpFileName0 = await Deno.makeTempFile(); // e.g. /tmp/419e0bf2 const tmpFileName1 = await Deno.makeTempFile({ prefix: 'my_temp' }); // e.g. /tmp/my_temp754d3098 ``` Requires `allow-write` permission.
f
Deno.makeTempFileSync
Synchronously creates a new temporary file in the default directory for temporary files, unless `dir` is specified. Other options include prefixing and suffixing the directory name with `prefix` and `suffix` respectively. The full path to the newly created file is returned. Multiple programs calling this function simultaneously will create different files. It is the caller's responsibility to remove the file when no longer needed. ```ts const tempFileName0 = Deno.makeTempFileSync(); // e.g. /tmp/419e0bf2 const tempFileName1 = Deno.makeTempFileSync({ prefix: 'my_temp' }); // e.g. /tmp/my_temp754d3098 ``` Requires `allow-write` permission.
I
Deno.MakeTempOptions
Options which can be set when using [`Deno.makeTempDir`](./././~/Deno.makeTempDir), [`Deno.makeTempDirSync`](./././~/Deno.makeTempDirSync), [`Deno.makeTempFile`](./././~/Deno.makeTempFile), and [`Deno.makeTempFileSync`](./././~/Deno.makeTempFileSync).
I
f
Deno.memoryUsage
Returns an object describing the memory usage of the Deno process and the V8 subsystem measured in bytes.
f
Deno.mkdir
Creates a new directory with the specified path. ```ts await Deno.mkdir("new_dir"); await Deno.mkdir("nested/directories", { recursive: true }); await Deno.mkdir("restricted_access_dir", { mode: 0o700 }); ``` Defaults to throwing error if the directory already exists. Requires `allow-write` permission.
I
Deno.MkdirOptions
Options which can be set when using [`Deno.mkdir`](./././~/Deno.mkdir) and [`Deno.mkdirSync`](./././~/Deno.mkdirSync).
f
Deno.mkdirSync
Synchronously creates a new directory with the specified path. ```ts Deno.mkdirSync("new_dir"); Deno.mkdirSync("nested/directories", { recursive: true }); Deno.mkdirSync("restricted_access_dir", { mode: 0o700 }); ``` Defaults to throwing error if the directory already exists. Requires `allow-write` permission.
I
Deno.MulticastV4Membership
Represents membership of a IPv4 multicast group.
I
Deno.MulticastV6Membership
Represents membership of a IPv6 multicast group.
I
Deno.MxRecord
If [`Deno.resolveDns`](./././~/Deno.resolveDns) is called with `"MX"` record type specified, it will return an array of objects with this interface.
I
Deno.NaptrRecord
If [`Deno.resolveDns`](./././~/Deno.resolveDns) is called with `"NAPTR"` record type specified, it will return an array of objects with this interface.
T
Deno.NativeBigIntType
All BigInt number types for interfacing with foreign functions.
T
Deno.NativeBooleanType
The native boolean type for interfacing to foreign functions.
T
Deno.NativeBufferType
The native buffer type for interfacing to foreign functions.
T
Deno.NativeFunctionType
The native function type for interfacing with foreign functions.
T
Deno.NativeI16Enum
No documentation available
T
Deno.NativeI32Enum
No documentation available
T
Deno.NativeI8Enum
No documentation available
T
Deno.NativeNumberType
All plain number types for interfacing with foreign functions.
T
Deno.NativePointerType
The native pointer type for interfacing to foreign functions.
T
Deno.NativeResultType
No documentation available
I
Deno.NativeStructType
The native struct type for interfacing with foreign functions.
T
Deno.NativeType
All supported types for interfacing with foreign functions.
T
Deno.NativeTypedFunction
No documentation available
T
Deno.NativeTypedPointer
No documentation available
T
Deno.NativeU16Enum
No documentation available
T
Deno.NativeU32Enum
No documentation available
T
Deno.NativeU8Enum
No documentation available
T
Deno.NativeVoidType
The native void type for interfacing with foreign functions.
I
Deno.NetAddr
No documentation available
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.NetworkInterfaceInfo
The information for a network interface returned from a call to [`Deno.networkInterfaces`](./././~/Deno.networkInterfaces).
f
Deno.networkInterfaces
Returns an array of the network interface information. ```ts console.log(Deno.networkInterfaces()); ``` Requires `allow-sys` permission.
v
Deno.noColor
Reflects the `NO_COLOR` environment variable at program start. When the value is `true`, the Deno CLI will attempt to not send color codes to `stderr` or `stdout` and other command line programs should also attempt to respect this value. See: https://no-color.org/
f
Deno.open
Open a file and resolve to an instance of [`Deno.FsFile`](./././~/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. ```ts using file = await Deno.open("/foo/bar.txt", { read: true, write: true }); // Do work with file ``` Alternatively, the caller may manually close the resource when finished with it. ```ts const file = await Deno.open("/foo/bar.txt", { read: true, write: true }); // Do work with file file.close(); ``` Requires `allow-read` and/or `allow-write` permissions depending on options.
f
Deno.openKv
Open a new [`Deno.Kv`](./././~/Deno.Kv) connection to persist data. When a path is provided, the database will be persisted to disk at that path. Read and write access to the file is required. When no path is provided, the database will be opened in a default path for the current script. This location is persistent across script runs and is keyed on the origin storage key (the same key that is used to determine `localStorage` persistence). More information about the origin storage key can be found in the Deno Manual.
I
Deno.OpenOptions
Options which can be set when doing [`Deno.open`](./././~/Deno.open) and [`Deno.openSync`](./././~/Deno.openSync).
f
Deno.openSync
Synchronously open a file and return an instance of [`Deno.FsFile`](./././~/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. ```ts using file = Deno.openSync("/foo/bar.txt", { read: true, write: true }); // Do work with file ``` Alternatively, the caller may manually close the resource when finished with it. ```ts const file = Deno.openSync("/foo/bar.txt", { read: true, write: true }); // Do work with file file.close(); ``` Requires `allow-read` and/or `allow-write` permissions depending on options.
f
Deno.osRelease
Returns the release version of the Operating System. ```ts console.log(Deno.osRelease()); ``` Requires `allow-sys` permission. Under consideration to possibly move to Deno.build or Deno.versions and if it should depend sys-info, which may not be desirable.
f
Deno.osUptime
Returns the Operating System uptime in number of seconds. ```ts console.log(Deno.osUptime()); ``` Requires `allow-sys` permission.
T
Deno.PermissionDescriptor
Permission descriptors which define a permission and can be queried, requested, or revoked. View the specifics of the individual descriptors for more information about each permission kind.
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. `"inherit"` ensures that all permissions of the parent process will be applied to the test context. `"none"` ensures the test context has no permissions. A `PermissionOptionsObject` provides a more specific set of permissions to the test context.
I
Deno.PermissionOptionsObject
A set of options which can define the permissions within a test or worker context at a highly specific level.
c
Deno.Permissions
Deno's permission management API. The class which provides the interface for the [`Deno.permissions`](./././~/Deno.permissions) global instance and is based on the web platform [Permissions API](https://developer.mozilla.org/en-US/docs/Web/API/Permissions_API), though some proposed parts of the API which are useful in a server side runtime context were removed or abandoned in the web platform specification which is why it was chosen to locate it in the [`Deno`](./././~/Deno) namespace instead. By default, if the `stdin`/`stdout` is TTY for the Deno CLI (meaning it can send and receive text), then the CLI will prompt the user to grant permission when an un-granted permission is requested. This behavior can be changed by using the `--no-prompt` command at startup. When prompting the CLI will request the narrowest permission possible, potentially making it annoying to the user. The permissions APIs allow the code author to request a wider set of permissions at one time in order to provide a better user experience.
v
Deno.permissions
Deno's permission management API. It is a singleton instance of the `Permissions` object and is based on the web platform [Permissions API](https://developer.mozilla.org/en-US/docs/Web/API/Permissions_API), though some proposed parts of the API which are useful in a server side runtime context were removed or abandoned in the web platform specification which is why it was chosen to locate it in the [`Deno`](./././~/Deno) namespace instead. By default, if the `stdin`/`stdout` is TTY for the Deno CLI (meaning it can send and receive text), then the CLI will prompt the user to grant permission when an un-granted permission is requested. This behavior can be changed by using the `--no-prompt` command at startup. When prompting the CLI will request the narrowest permission possible, potentially making it annoying to the user. The permissions APIs allow the code author to request a wider set of permissions at one time in order to provide a better user experience. Requesting already granted permissions will not prompt the user and will return that the permission was granted. ### Querying ```ts const status = await Deno.permissions.query({ name: "read", path: "/etc" }); console.log(status.state); ``` ```ts const status = Deno.permissions.querySync({ name: "read", path: "/etc" }); console.log(status.state); ``` ### Revoking ```ts import { assert } from "jsr:@std/assert"; const status = await Deno.permissions.revoke({ name: "run" }); assert(status.state !== "granted") ``` ```ts import { assert } from "jsr:@std/assert"; const status = Deno.permissions.revokeSync({ name: "run" }); assert(status.state !== "granted") ``` ### Requesting ```ts const status = await Deno.permissions.request({ name: "env" }); if (status.state === "granted") { console.log("'env' permission is granted."); } else { console.log("'env' permission is denied."); } ``` ```ts const status = Deno.permissions.requestSync({ name: "env" }); if (status.state === "granted") { console.log("'env' permission is granted."); } else { console.log("'env' permission is denied."); } ```
T
Deno.PermissionState
The current status of the permission: - `"granted"` - the permission has been granted. - `"denied"` - the permission has been explicitly denied. - `"prompt"` - the permission has not explicitly granted nor denied.
c
Deno.PermissionStatus
An `EventTarget` returned from the [`Deno.permissions`](./././~/Deno.permissions) API which can provide updates to any state changes of the permission.
I
Deno.PermissionStatusEventMap
The interface which defines what event types are supported by `PermissionStatus` instances.
v
Deno.pid
The current process ID of this instance of the Deno CLI. ```ts console.log(Deno.pid); ```
I
Deno.PointerObject
A non-null pointer, represented as an object at runtime. The object's prototype is `null` and cannot be changed. The object cannot be assigned to either and is thus entirely read-only. To interact with memory through a pointer use the `UnsafePointerView` class. To create a pointer from an address or the get the address of a pointer use the static methods of the `UnsafePointer` class.
T
Deno.PointerValue
Pointers are represented either with a `PointerObject` object or a `null` if the pointer is null.
v
Deno.ppid
The process ID of parent process of this instance of the Deno CLI. ```ts console.log(Deno.ppid); ```
I
Deno.Proxy
The definition of a proxy when specifying [`Deno.CreateHttpClientOptions`](./././~/Deno.CreateHttpClientOptions).
f
Deno.readDir
Reads the directory given by `path` and returns an async iterable of [`Deno.DirEntry`](./././~/Deno.DirEntry). The order of entries is not guaranteed. ```ts for await (const dirEntry of Deno.readDir("/")) { console.log(dirEntry.name); } ``` Throws error if `path` is not a directory. Requires `allow-read` permission.
f
Deno.readDirSync
Synchronously reads the directory given by `path` and returns an iterable of [`Deno.DirEntry`](./././~/Deno.DirEntry). The order of entries is not guaranteed. ```ts for (const dirEntry of Deno.readDirSync("/")) { console.log(dirEntry.name); } ``` Throws error if `path` is not a directory. Requires `allow-read` permission.
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. Reading a directory returns an empty data array. ```ts const decoder = new TextDecoder("utf-8"); const data = await Deno.readFile("hello.txt"); console.log(decoder.decode(data)); ``` Requires `allow-read` permission.
I
Deno.ReadFileOptions
Options which can be set when using [`Deno.readFile`](./././~/Deno.readFile) or [`Deno.readFileSync`](./././~/Deno.readFileSync).
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. Reading a directory returns an empty data array. ```ts const decoder = new TextDecoder("utf-8"); const data = Deno.readFileSync("hello.txt"); console.log(decoder.decode(data)); ``` Requires `allow-read` permission.
f
Deno.readLinkSync
Synchronously returns the full path destination of the named symbolic link. ```ts Deno.symlinkSync("./test.txt", "./test_link.txt"); const target = Deno.readLinkSync("./test_link.txt"); // full path of ./test.txt ``` Throws TypeError if called with a hard link. Requires `allow-read` permission.
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). Permission granted under `allow-read` only allows runtime code to attempt to read, the underlying operating system may apply additional permissions.
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. ```ts const data = await Deno.readTextFile("hello.txt"); console.log(data); ``` Requires `allow-read` permission.
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. ```ts const data = Deno.readTextFileSync("hello.txt"); console.log(data); ``` Requires `allow-read` permission.
f
Deno.realPath
Resolves to the absolute normalized path, with symbolic links resolved. ```ts // e.g. given /home/alice/file.txt and current directory /home/alice await Deno.symlink("file.txt", "symlink_file.txt"); const realPath = await Deno.realPath("./file.txt"); const realSymLinkPath = await Deno.realPath("./symlink_file.txt"); console.log(realPath); // outputs "/home/alice/file.txt" console.log(realSymLinkPath); // outputs "/home/alice/file.txt" ``` Requires `allow-read` permission for the target path. Also requires `allow-read` permission for the `CWD` if the target path is relative.
f
Deno.realPathSync
Synchronously returns absolute normalized path, with symbolic links resolved. ```ts // e.g. given /home/alice/file.txt and current directory /home/alice Deno.symlinkSync("file.txt", "symlink_file.txt"); const realPath = Deno.realPathSync("./file.txt"); const realSymLinkPath = Deno.realPathSync("./symlink_file.txt"); console.log(realPath); // outputs "/home/alice/file.txt" console.log(realSymLinkPath); // outputs "/home/alice/file.txt" ``` Requires `allow-read` permission for the target path. Also requires `allow-read` permission for the `CWD` if the target path is relative.
T
Deno.RecordType
The type of the resource record to resolve via DNS using [`Deno.resolveDns`](./././~/Deno.resolveDns). Only the listed types are supported currently.
f
Deno.refTimer
Make the timer of the given `id` block the event loop from finishing.
f
Deno.remove
Removes the named file or directory. ```ts await Deno.remove("/path/to/empty_dir/or/file"); await Deno.remove("/path/to/populated_dir/or/file", { recursive: true }); ``` Throws error if permission denied, path not found, or path is a non-empty directory and the `recursive` option isn't set to `true`. Requires `allow-write` permission.
I
Deno.RemoveOptions
Options which can be set when using [`Deno.remove`](./././~/Deno.remove) and [`Deno.removeSync`](./././~/Deno.removeSync).
f
Deno.removeSignalListener
Removes the given signal listener that has been registered with [`Deno.addSignalListener`](./././~/Deno.addSignalListener). ```ts const listener = () => { console.log("SIGTERM!") }; Deno.addSignalListener("SIGTERM", listener); Deno.removeSignalListener("SIGTERM", listener); ``` _Note_: On Windows only `"SIGINT"` (CTRL+C) and `"SIGBREAK"` (CTRL+Break) are supported.
f
Deno.removeSync
Synchronously removes the named file or directory. ```ts Deno.removeSync("/path/to/empty_dir/or/file"); Deno.removeSync("/path/to/populated_dir/or/file", { recursive: true }); ``` Throws error if permission denied, path not found, or path is a non-empty directory and the `recursive` option isn't set to `true`. Requires `allow-write` permission.
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. ```ts await Deno.rename("old/path", "new/path"); ``` On Unix-like OSes, this operation does not follow symlinks at either path. It varies between platforms when the operation throws errors, and if so what they are. It's always an error to rename anything to a non-empty directory. Requires `allow-read` and `allow-write` permissions.
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. ```ts Deno.renameSync("old/path", "new/path"); ``` On Unix-like OSes, this operation does not follow symlinks at either path. It varies between platforms when the operation throws errors, and if so what they are. It's always an error to rename anything to a non-empty directory. Requires `allow-read` and `allow-write` permissions.
f
Deno.resolveDns
Performs DNS resolution against the given query, returning resolved records. Fails in the cases such as: - the query is in invalid format. - the options have an invalid parameter. For example `nameServer.port` is beyond the range of 16-bit unsigned integer. - the request timed out. ```ts const a = await Deno.resolveDns("example.com", "A"); const aaaa = await Deno.resolveDns("example.com", "AAAA", { nameServer: { ipAddr: "8.8.8.8", port: 53 }, }); ``` Requires `allow-net` permission.
I
Deno.ResolveDnsOptions
Options which can be set when using [`Deno.resolveDns`](./././~/Deno.resolveDns).
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. **Warning, in practice, `allow-run` is effectively the same as `allow-all` in the sense that malicious code could execute any arbitrary code on the host.**
E
Deno.SeekMode
A enum which defines the seek mode for IO related APIs that support seeking.
f
Deno.serve
Serves HTTP requests with the given handler. The below example serves with the port `8000` on hostname `"127.0.0.1"`. ```ts Deno.serve((_req) => new Response("Hello, world")); ```
I
Deno.ServeDefaultExport
Interface that module run with `deno serve` subcommand must conform to. To ensure your code is type-checked properly, make sure to add `satisfies Deno.ServeDefaultExport` to the `export default { ... }` like so: ```ts export default { fetch(req) { return new Response("Hello world"); } } satisfies Deno.ServeDefaultExport; ```
T
Deno.ServeHandler
A handler for HTTP requests. Consumes a request and returns a response. If a handler throws, the server calling the handler will assume the impact of the error is isolated to the individual request. It will catch the error and if necessary will close the underlying connection.
I
Deno.ServeHandlerInfo
Additional information for an HTTP request and its connection.
I
Deno.ServeInit
No documentation available
I
Deno.ServeOptions
Options which can be set when calling [`Deno.serve`](./././~/Deno.serve).
I
Deno.ServeTcpOptions
Options that can be passed to `Deno.serve` to create a server listening on a TCP port.
I
Deno.ServeUnixOptions
Options that can be passed to `Deno.serve` to create a server listening on a Unix domain socket.
I
Deno.SetRawOptions
No documentation available
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.
I
Deno.SoaRecord
If [`Deno.resolveDns`](./././~/Deno.resolveDns) is called with `"SOA"` record type specified, it will return an array of objects with this interface.
I
Deno.SrvRecord
If [`Deno.resolveDns`](./././~/Deno.resolveDns) is called with `"SRV"` record type specified, it will return an array of objects with this interface.
f
Deno.startTls
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. Note that this function *consumes* the TCP connection passed to it, thus the original TCP connection will be unusable after calling this. Additionally, you need to ensure that the TCP connection is not being used elsewhere when calling this function in order for the TCP connection to be consumed properly. For instance, if there is a `Promise` that is waiting for read operation on the TCP connection to complete, it is considered that the TCP connection is being used elsewhere. In such a case, this function will fail. ```ts const conn = await Deno.connect({ port: 80, hostname: "127.0.0.1" }); const caCert = await Deno.readTextFile("./certs/my_custom_root_CA.pem"); // `conn` becomes unusable after calling `Deno.startTls` const tlsConn = await Deno.startTls(conn, { caCerts: [caCert], hostname: "localhost" }); ``` Requires `allow-net` permission.
f
Deno.stat
Resolves to a [`Deno.FileInfo`](./././~/Deno.FileInfo) for the specified `path`. Will always follow symlinks. ```ts import { assert } from "jsr:@std/assert"; const fileInfo = await Deno.stat("hello.txt"); assert(fileInfo.isFile); ``` Requires `allow-read` permission.
T
Deno.StaticForeignLibraryInterface
A utility type that infers a foreign library interface.
T
Deno.StaticForeignSymbol
A utility type that infers a foreign symbol.
T
Deno.StaticForeignSymbolReturnType
No documentation available
f
Deno.statSync
Synchronously returns a [`Deno.FileInfo`](./././~/Deno.FileInfo) for the specified `path`. Will always follow symlinks. ```ts import { assert } from "jsr:@std/assert"; const fileInfo = Deno.statSync("hello.txt"); assert(fileInfo.isFile); ``` Requires `allow-read` permission.
v
Deno.stderr
A reference to `stderr` which can be used to write directly to `stderr`. It implements the Deno specific [`Writer`](https://jsr.io/@std/io/doc/types/~/Writer), [`WriterSync`](https://jsr.io/@std/io/doc/types/~/WriterSync), and [`Closer`](https://jsr.io/@std/io/doc/types/~/Closer) interfaces as well as provides a `WritableStream` interface. These are low level constructs, and the `console` interface is a more straight forward way to interact with `stdout` and `stderr`.
v
Deno.stdin
A reference to `stdin` which can be used to read directly from `stdin`. It implements the Deno specific [`Reader`](https://jsr.io/@std/io/doc/types/~/Reader), [`ReaderSync`](https://jsr.io/@std/io/doc/types/~/ReaderSync), and [`Closer`](https://jsr.io/@std/io/doc/types/~/Closer) interfaces as well as provides a `ReadableStream` interface. ### Reading chunks from the readable stream ```ts const decoder = new TextDecoder(); for await (const chunk of Deno.stdin.readable) { const text = decoder.decode(chunk); // do something with the text } ```
v
Deno.stdout
A reference to `stdout` which can be used to write directly to `stdout`. It implements the Deno specific [`Writer`](https://jsr.io/@std/io/doc/types/~/Writer), [`WriterSync`](https://jsr.io/@std/io/doc/types/~/WriterSync), and [`Closer`](https://jsr.io/@std/io/doc/types/~/Closer) interfaces as well as provides a `WritableStream` interface. These are low level constructs, and the `console` interface is a more straight forward way to interact with `stdout` and `stderr`.
I
Deno.SymlinkOptions
Options that can be used with `symlink` and `symlinkSync`.
f
Deno.symlinkSync
Creates `newpath` as a symbolic link to `oldpath`. The `options.type` parameter can be set to `"file"`, `"dir"` or `"junction"`. This argument is only available on Windows and ignored on other platforms. ```ts Deno.symlinkSync("old/name", "new/name"); ``` Requires full `allow-read` and `allow-write` permissions.
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.SystemMemoryInfo
Information returned from a call to [`Deno.systemMemoryInfo`](./././~/Deno.systemMemoryInfo).
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. This is similar to the `free` command in Linux ```ts console.log(Deno.systemMemoryInfo()); ``` Requires `allow-sys` permission.
I
Deno.TcpConn
No documentation available
T
Deno.TcpListener
Specialized listener that accepts TCP connections.
I
Deno.TcpListenOptions
No documentation available
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. `fn` can be async if required. ```ts import { assertEquals } from "jsr:@std/assert"; Deno.test({ name: "example test", fn() { assertEquals("world", "world"); }, }); Deno.test({ name: "example ignored test", ignore: Deno.build.os === "windows", fn() { // This test is ignored only on Windows machines }, }); Deno.test({ name: "example async test", async fn() { const decoder = new TextDecoder("utf-8"); const data = await Deno.readFile("hello_world.txt"); assertEquals(decoder.decode(data), "Hello world"); } }); ```
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.TlsCertifiedKeyPem
Provides certified key material from strings. The key material is provided in `PEM`-format (Privacy Enhanced Mail, https://www.rfc-editor.org/rfc/rfc1422) which can be identified by having `-----BEGIN-----` and `-----END-----` markers at the beginning and end of the strings. This type of key is not compatible with `DER`-format keys which are binary. Deno supports RSA, EC, and PKCS8-format keys. ```ts const key = { key: "-----BEGIN PRIVATE KEY-----\n...\n-----END PRIVATE KEY-----\n", cert: "-----BEGIN CERTIFICATE-----\n...\n-----END CERTIFICATE-----\n" } }; ```
I
Deno.TlsConn
No documentation available
I
Deno.TlsHandshakeInfo
No documentation available
T
Deno.TlsListener
Specialized listener that accepts TLS connections.
T
Deno.ToNativeParameterTypes
A utility type for conversion of parameter types of foreign functions.
T
Deno.ToNativeResultType
Type conversion for unsafe callback return types.
T
Deno.ToNativeType
Type conversion for foreign symbol parameters and unsafe callback return types.
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. ### Truncate the entire file ```ts await Deno.truncate("my_file.txt"); ``` ### Truncate part of the file ```ts const file = await Deno.makeTempFile(); await Deno.writeTextFile(file, "Hello World"); await Deno.truncate(file, 7); const data = await Deno.readFile(file); console.log(new TextDecoder().decode(data)); // "Hello W" ``` Requires `allow-write` permission.
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. ### Truncate the entire file ```ts Deno.truncateSync("my_file.txt"); ``` ### Truncate part of the file ```ts const file = Deno.makeTempFileSync(); Deno.writeFileSync(file, new TextEncoder().encode("Hello World")); Deno.truncateSync(file, 7); const data = Deno.readFileSync(file); console.log(new TextDecoder().decode(data)); ``` Requires `allow-write` permission.
I
Deno.UdpListenOptions
Unstable options which can be set when opening a datagram listener via [`Deno.listenDatagram`](./././~/Deno.listenDatagram).
f
Deno.uid
Returns the user id of the process on POSIX platforms. Returns null on Windows. ```ts console.log(Deno.uid()); ``` Requires `allow-sys` permission.
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. ```ts console.log(Deno.umask()); // e.g. 18 (0o022) const prevUmaskValue = Deno.umask(0o077); // e.g. 18 (0o022) console.log(Deno.umask()); // e.g. 63 (0o077) ``` This API is under consideration to determine if permissions are required to call it. *Note*: This API is not implemented on Windows
I
Deno.UnixAddr
No documentation available
I
Deno.UnixConn
No documentation available
I
Deno.UnixConnectOptions
No documentation available
T
Deno.UnixListener
Specialized listener that accepts Unix connections.
I
Deno.UnixListenOptions
Options which can be set when opening a Unix listener via [`Deno.listen`](./././~/Deno.listen) or [`Deno.listenDatagram`](./././~/Deno.listenDatagram).
f
Deno.unrefTimer
Make the timer of the given `id` not block the event loop from finishing.
c
Deno.UnsafeCallback
An unsafe function pointer for passing JavaScript functions as C function pointers to foreign function calls. The function pointer remains valid until the `close()` method is called. All `UnsafeCallback` are always thread safe in that they can be called from foreign threads without crashing. However, they do not wake up the Deno event loop by default. If a callback is to be called from foreign threads, use the `threadSafe()` static constructor or explicitly call `ref()` to have the callback wake up the Deno event loop when called from foreign threads. This also stops Deno's process from exiting while the callback still exists and is not unref'ed. Use `deref()` to then allow Deno's process to exit. Calling `deref()` on a ref'ed callback does not stop it from waking up the Deno event loop when called from foreign threads.
I
Deno.UnsafeCallbackDefinition
Definition of a unsafe callback function.
T
Deno.UnsafeCallbackFunction
An unsafe callback function.
c
Deno.UnsafeFnPointer
An unsafe pointer to a function, for calling functions that are not present as symbols.
c
Deno.UnsafePointer
A collection of static functions for interacting with pointer objects.
c
Deno.UnsafePointerView
An unsafe pointer view to a memory location as specified by the `pointer` value. The `UnsafePointerView` API follows the standard built in interface `DataView` for accessing the underlying types at an memory location (numbers, strings and raw bytes).
c
Deno.UnsafeWindowSurface
Creates a presentable WebGPU surface from given window and display handles. The parameters correspond to the table below: | system | winHandle | displayHandle | | ----------------- | ------------- | --------------- | | "cocoa" (macOS) | `NSView*` | - | | "win32" (Windows) | `HWND` | `HINSTANCE` | | "x11" (Linux) | Xlib `Window` | Xlib `Display*` | | "wayland" (Linux) | `wl_surface*` | `wl_display*` |
f
Deno.upgradeWebSocket
Upgrade an incoming HTTP request to a WebSocket. Given a `Request`, returns a pair of `WebSocket` and `Response` instances. The original request must be responded to with the returned response for the websocket upgrade to be successful. ```ts Deno.serve((req) => { if (req.headers.get("upgrade") !== "websocket") { return new Response(null, { status: 501 }); } const { socket, response } = Deno.upgradeWebSocket(req); socket.addEventListener("open", () => { console.log("a client connected!"); }); socket.addEventListener("message", (event) => { if (event.data === "ping") { socket.send("pong"); } }); return response; }); ``` If the request body is disturbed (read from) before the upgrade is completed, upgrading fails. This operation does not yet consume the request or open the websocket. This only happens once the returned response has been passed to `respondWith()`.
I
Deno.UpgradeWebSocketOptions
Options which can be set when performing a [`Deno.upgradeWebSocket`](./././~/Deno.upgradeWebSocket) upgrade of a `Request`
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. ```ts await Deno.utime("myfile.txt", 1556495550, new Date()); ``` Requires `allow-write` permission.
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. ```ts Deno.utimeSync("myfile.txt", 1556495550, new Date()); ``` Requires `allow-write` permission.
v
Deno.version
Version information related to the current Deno CLI runtime environment. Users are discouraged from code branching based on this information, as assumptions about what is available in what build environment might change over time. Developers should specifically sniff out the features they intend to use. The intended use for the information is for logging and debugging purposes.
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`). The 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. ```ts const watcher = Deno.watchFs("/"); for await (const event of watcher) { console.log(">>>> event", event); // { kind: "create", paths: [ "/foo.txt" ] } } ``` Call `watcher.close()` to stop watching. ```ts const watcher = Deno.watchFs("/"); setTimeout(() => { watcher.close(); }, 5000); for await (const event of watcher) { console.log(">>>> event", event); } ``` Requires `allow-read` permission.
I
Deno.WebSocketUpgrade
The object that is returned from a [`Deno.upgradeWebSocket`](./././~/Deno.upgradeWebSocket) request.
f
Deno.writeFile
Write `data` to the given `path`, by default creating a new file if needed, else overwriting. ```ts const encoder = new TextEncoder(); const data = encoder.encode("Hello world\n"); await Deno.writeFile("hello1.txt", data); // overwrite "hello1.txt" or create it await Deno.writeFile("hello2.txt", data, { create: false }); // only works if "hello2.txt" exists await Deno.writeFile("hello3.txt", data, { mode: 0o777 }); // set permissions on new file await Deno.writeFile("hello4.txt", data, { append: true }); // add data to the end of the file ``` Requires `allow-write` permission, and `allow-read` if `options.create` is `false`.
I
f
Deno.writeFileSync
Synchronously write `data` to the given `path`, by default creating a new file if needed, else overwriting. ```ts const encoder = new TextEncoder(); const data = encoder.encode("Hello world\n"); Deno.writeFileSync("hello1.txt", data); // overwrite "hello1.txt" or create it Deno.writeFileSync("hello2.txt", data, { create: false }); // only works if "hello2.txt" exists Deno.writeFileSync("hello3.txt", data, { mode: 0o777 }); // set permissions on new file Deno.writeFileSync("hello4.txt", data, { append: true }); // add data to the end of the file ``` Requires `allow-write` permission, and `allow-read` if `options.create` is `false`.
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). Permission granted under `allow-write` only allows runtime code to attempt to write, the underlying operating system may apply additional permissions.
f
Deno.writeTextFile
Write string `data` to the given `path`, by default creating a new file if needed, else overwriting. ```ts await Deno.writeTextFile("hello1.txt", "Hello world\n"); // overwrite "hello1.txt" or create it ``` Requires `allow-write` permission, and `allow-read` if `options.create` is `false`.
f
Deno.writeTextFileSync
Synchronously write string `data` to the given `path`, by default creating a new file if needed, else overwriting. ```ts Deno.writeTextFileSync("hello1.txt", "Hello world\n"); // overwrite "hello1.txt" or create it ``` Requires `allow-write` permission, and `allow-read` if `options.create` is `false`.