Platform
function alert
alert(message?: string): voidShows the given message and waits for the enter key pressed.
If the stdin is not interactive, it does nothing.
Examples
// Displays the message "Acknowledge me! [Enter]" and waits for the enter key to be pressed before continuing.
alert("Acknowledge me!");
Parameters
message: string Return Type
void See
function close
close(): voidExits the current Deno process.
This function terminates the process by signaling the runtime to exit. Similar to exit(0) in posix. Its behavior is similar to the window.close() method in the browser, but specific to the Deno runtime.
Note: Use this function cautiously, as it will stop the execution of the entire Deno program immediately.
Examples
console.log("About to close the Deno process.");
close(); // The process will terminate here.
console.log("This will not be logged."); // This line will never execute.
Return Type
void See
function confirm
confirm(message?: string): booleanShows the given message and waits for the answer. Returns the user's answer as boolean.
Only y and Y are considered as true.
If the stdin is not interactive, it returns false.
Examples
const shouldProceed = confirm("Do you want to proceed?");
// If the user presses 'y' or 'Y', the result will be true
// If the user presses 'n' or 'N', the result will be false
console.log("Should proceed?", shouldProceed);
Parameters
message: string Return Type
boolean See
function prompt
prompt(
message?: string,
defaultValue?: string,
): string | nullShows the given message and waits for the user's input. Returns the user's input as string.
If the default value is given and the user inputs the empty string, then it returns the given default value.
If the default value is not given and the user inputs the empty string, it returns the empty string.
If the stdin is not interactive, it returns null.
Examples
const pet = prompt("Cats or dogs?", "It's fine to love both!");
// Displays the user's input or the default value of "It's fine to love both!"
console.log("Best pet:", pet);
Parameters
message: string defaultValue: string Return Type
string | null See
function queueMicrotask
queueMicrotask(func: VoidFunction): voidA microtask is a short function which is executed after the function or module which created it exits and only if the JavaScript execution stack is empty, but before returning control to the event loop being used to drive the script's execution environment. This event loop may be either the main event loop or the event loop driving a web worker.
queueMicrotask(() => { console.log('This event loop stack is complete'); });
Parameters
func: VoidFunction Return Type
void function reportError
reportError(error: any): voidDispatch an uncaught exception. Similar to a synchronous version of:
setTimeout(() => { throw error; }, 0);
The error can not be caught with a try/catch block. An error event will be dispatched to the global scope. You can prevent the error from being reported to the console with Event.prototype.preventDefault():
addEventListener("error", (event) => {
event.preventDefault();
});
reportError(new Error("foo")); // Will not be reported.
In Deno, this error will terminate the process if not intercepted like above.
Parameters
error: any Return Type
void function structuredClone
structuredClone<T = any>(
value: T,
options?: StructuredSerializeOptions,
): TCreates a deep copy of a given value using the structured clone algorithm.
Unlike a shallow copy, a deep copy does not hold the same references as the source object, meaning its properties can be changed without affecting the source. For more details, see MDN.
Throws a DataCloneError if any part of the input value is not serializable.
Examples
const object = { x: 0, y: 1 };
const deepCopy = structuredClone(object);
deepCopy.x = 1;
console.log(deepCopy.x, object.x); // 1 0
const shallowCopy = object;
shallowCopy.x = 1;
// shallowCopy.x is pointing to the same location in memory as object.x
console.log(shallowCopy.x, object.x); // 1 1
Type Parameters
T = any Parameters
value: T options: StructuredSerializeOptions Return Type
interface AbortController
A controller object that allows you to abort one or more DOM requests as and when desired.
Properties
signal: AbortSignal Returns the AbortSignal object associated with this object.
Methods
abort(reason?: any): void Invoking this method will set this object's AbortSignal's aborted flag and signal to any observers that the associated activity is to be aborted.
variable AbortController
A controller object that allows you to abort one or more DOM requests as and when desired.
Properties
prototype: AbortController interface AbortSignal
A signal object that allows you to communicate with a DOM request (such as a Fetch) and abort it if required via an AbortController object.
Properties
aborted: boolean Returns true if this AbortSignal's AbortController has signaled to abort, and false otherwise.
reason: any onabort: ((
this: AbortSignal,
ev: Event,
) => any) | null Methods
addEventListener<K extends keyof AbortSignalEventMap>(
type: K,
listener: (
this: AbortSignal,
ev: AbortSignalEventMap[K],
) => any,
options?: boolean | AddEventListenerOptions,
): void addEventListener(
type: string,
listener: EventListenerOrEventListenerObject,
options?: boolean | AddEventListenerOptions,
): void removeEventListener<K extends keyof AbortSignalEventMap>(
type: K,
listener: (
this: AbortSignal,
ev: AbortSignalEventMap[K],
) => any,
options?: boolean | EventListenerOptions,
): void removeEventListener(
type: string,
listener: EventListenerOrEventListenerObject,
options?: boolean | EventListenerOptions,
): void throwIfAborted(): void Throws this AbortSignal's abort reason, if its AbortController has signaled to abort; otherwise, does nothing.
variable AbortSignal
The constructor object for AbortSignal.
AbortSignal instances are obtained from an AbortController or via the static abort, timeout, and any factory methods rather than constructed directly, so calling the constructor throws.
Properties
prototype: AbortSignal Methods
abort(reason?: any): AbortSignal any(signals: AbortSignal[]): AbortSignal timeout(milliseconds: number): AbortSignal interface AbortSignalEventMap
interface CSSRule
A single CSS rule of a CSSStyleSheet, as returned from its cssRules property. Available only when the --unstable-raw-imports flag is enabled.
Note: cssText is the verbatim text of one top-level rule of the style sheet; Deno does not implement a full CSS object model.
Properties
cssText: string interface CSSStyleSheet
A style sheet backing a CSS module script. This is what a import sheet from "./styles.css" with { type: "css" } import evaluates to. Available only when the --unstable-raw-imports flag is enabled.
Deno has no DOM, so a sheet can't be adopted anywhere; the implementation is backed by the raw CSS text.
Note: cssRules returns a frozen array of CSSRule instead of a live CSSRuleList.
Properties
Methods
replace(text: string): Promise<CSSStyleSheet> replaceSync(text: string): void interface DOMException
Properties
name: string message: string code: number INDEX_SIZE_ERR: 1 DOMSTRING_SIZE_ERR: 2 HIERARCHY_REQUEST_ERR: 3 WRONG_DOCUMENT_ERR: 4 INVALID_CHARACTER_ERR: 5 NO_DATA_ALLOWED_ERR: 6 NO_MODIFICATION_ALLOWED_ERR: 7 NOT_FOUND_ERR: 8 NOT_SUPPORTED_ERR: 9 INUSE_ATTRIBUTE_ERR: 10 INVALID_STATE_ERR: 11 SYNTAX_ERR: 12 INVALID_MODIFICATION_ERR: 13 NAMESPACE_ERR: 14 INVALID_ACCESS_ERR: 15 VALIDATION_ERR: 16 TYPE_MISMATCH_ERR: 17 SECURITY_ERR: 18 NETWORK_ERR: 19 ABORT_ERR: 20 URL_MISMATCH_ERR: 21 QUOTA_EXCEEDED_ERR: 22 TIMEOUT_ERR: 23 INVALID_NODE_TYPE_ERR: 24 DATA_CLONE_ERR: 25 variable DOMException
The constructor object for DOMException, used to construct an exception describing an abnormal event raised by a web API. It also exposes the legacy numeric error code constants (e.g. ABORT_ERR).
Properties
prototype: DOMException INDEX_SIZE_ERR: 1 DOMSTRING_SIZE_ERR: 2 HIERARCHY_REQUEST_ERR: 3 WRONG_DOCUMENT_ERR: 4 INVALID_CHARACTER_ERR: 5 NO_DATA_ALLOWED_ERR: 6 NO_MODIFICATION_ALLOWED_ERR: 7 NOT_FOUND_ERR: 8 NOT_SUPPORTED_ERR: 9 INUSE_ATTRIBUTE_ERR: 10 INVALID_STATE_ERR: 11 SYNTAX_ERR: 12 INVALID_MODIFICATION_ERR: 13 NAMESPACE_ERR: 14 INVALID_ACCESS_ERR: 15 VALIDATION_ERR: 16 TYPE_MISMATCH_ERR: 17 SECURITY_ERR: 18 NETWORK_ERR: 19 ABORT_ERR: 20 URL_MISMATCH_ERR: 21 QUOTA_EXCEEDED_ERR: 22 TIMEOUT_ERR: 23 INVALID_NODE_TYPE_ERR: 24 DATA_CLONE_ERR: 25 interface DOMStringList
Index Signatures
Properties
length: number Returns the number of strings in strings.
Methods
interface ErrorConstructor
Properties
stackTraceLimit: number Methods
captureStackTrace(
error: Object,
constructor?: Function,
): void interface ImageData
Properties
width: number height: number data: ImageDataArray pixelFormat: ImageDataPixelFormat colorSpace: PredefinedColorSpace interface ImageDataSettings
Properties
colorSpace: PredefinedColorSpace pixelFormat: ImageDataPixelFormat interface ImportMeta
Deno provides extra properties on import.meta. These are included here to ensure that these are still available when using the Deno namespace in conjunction with other type libs, like dom.
Properties
url: string A string representation of the fully qualified module URL. When the module is loaded locally, the value will be a file URL (e.g. file:///path/module.ts).
You can also parse the string as a URL to determine more information about how the current module was loaded. For example to determine if a module was local or not:
const url = new URL(import.meta.url);
if (url.protocol === "file:") {
console.log("this module was loaded locally");
}
filename: string The absolute path of the current module.
This property is only provided for local modules (ie. using file:// URLs).
Example:
// Unix
console.log(import.meta.filename); // /home/alice/my_module.ts
// Windows
console.log(import.meta.filename); // C:\alice\my_module.ts
dirname: string The absolute path of the directory containing the current module.
This property is only provided for local modules (ie. using file:// URLs).
- Example:
// Unix
console.log(import.meta.dirname); // /home/alice
// Windows
console.log(import.meta.dirname); // C:\alice
main: boolean A flag that indicates if the current module is the main module that was called when starting the program under Deno.
if (import.meta.main) {
// this was loaded as the main module, maybe do some bootstrapping
}
Methods
resolve(specifier: string): string A function that returns resolved specifier as if it would be imported using import(specifier).
console.log(import.meta.resolve("./foo.js"));
// file:///dev/foo.js
interface Location
The location (URL) of the object it is linked to. Changes done on it are reflected on the object it relates to. Accessible via globalThis.location.
Properties
ancestorOrigins: DOMStringList Returns a DOMStringList object listing the origins of the ancestor browsing contexts, from the parent browsing context to the top-level browsing context.
Always empty in Deno.
hash: string Returns the Location object's URL's fragment (includes leading "#" if non-empty).
Cannot be set in Deno.
host: string Returns the Location object's URL's host and port (if different from the default port for the scheme).
Cannot be set in Deno.
hostname: string Returns the Location object's URL's host.
Cannot be set in Deno.
href: string Returns the Location object's URL.
Cannot be set in Deno.
origin: string Returns the Location object's URL's origin.
pathname: string Returns the Location object's URL's path.
Cannot be set in Deno.
port: string Returns the Location object's URL's port.
Cannot be set in Deno.
protocol: string Returns the Location object's URL's scheme.
Cannot be set in Deno.
search: string Returns the Location object's URL's query (includes leading "?" if non-empty).
Cannot be set in Deno.
Methods
toString(): string assign(url: string): void Navigates to the given URL.
Cannot be set in Deno.
reload(): void Reloads the current page.
Disabled in Deno.
reload(forcedReload: boolean): void replace(url: string): void Removes the current page from the session history and navigates to the given URL.
Disabled in Deno.
interface Math
Methods
sumPrecise(values: Iterable<number>): number Returns the sum of the given values using a more precise algorithm than a naive +-based reduction, avoiding the floating-point rounding errors that accumulate when summing many numbers.
interface Navigator
Provides information about the Deno runtime environment and the system on which it's running. Similar to the browser Navigator object but adapted for the Deno context.
variable Navigator
Constructor for Navigator objects.
Note: This constructor cannot be used to create new Navigator instances in Deno. The global navigator object is pre-defined in the runtime environment.
interface NavigatorUABrandVersion
A brand and version pair describing a user agent, as returned by NavigatorUAData.
interface NavigatorUAData
Gives access to information about the runtime's user agent, exposed via Navigator.userAgentData. This is the User-Agent Client Hints API.
variable NavigatorUAData
Constructor for NavigatorUAData objects.
Note: This constructor cannot be used to create new NavigatorUAData instances in Deno.
interface QuotaExceededError
variable QuotaExceededError
The constructor object for QuotaExceededError, used to construct an error thrown when an operation would exceed an enforced quota.
Properties
prototype: QuotaExceededError interface QuotaExceededErrorOptions
interface RegExpConstructor
Methods
escape(string: string): string Returns a new string in which characters that are potentially special in a regular expression pattern are replaced with escape sequences.
interface StructuredSerializeOptions
Options that control structured serialization operations such as structuredClone(value, options) and MessagePort.postMessage(message, options).
The optional transfer array lists Transferable objects whose underlying resources should be moved (transferred) to the receiving side instead of being cloned. After a successful transfer:
- For an
ArrayBuffer, the original buffer becomes neutered (itsbyteLengthis set to0). - For a
MessagePort, the port becomes unusable on the sending side and future events will arrive only on the transferred port at the receiver.
Validation rules:
- Each transferable may appear only once in the
transferlist. - A
MessagePortcannot be listed together with its counterpart port from the sameMessageChannelin the same transfer operation. - Duplicate or otherwise invalid entries will cause a
DataCloneErrorDOMExceptionto be thrown.
Transferring improves performance for large binary data and allows moving communication endpoints without copying.
Examples
// Transferring an ArrayBuffer (zero-copy for large data)
const buffer = new ArrayBuffer(16);
const cloned = structuredClone(buffer, { transfer: [buffer] });
// After transfer, the original buffer is neutered
console.log(buffer.byteLength); // 0
console.log(cloned.byteLength); // 16
Properties
transfer: Transferable[] List of transferable objects whose ownership is moved instead of cloned.
interface UADataValues
The values returned by NavigatorUAData.getHighEntropyValues.
Properties
brands: NavigatorUABrandVersion[] mobile: boolean platform: string architecture: string bitness: string formFactors: string[] fullVersionList: NavigatorUABrandVersion[] model: string platformVersion: string uaFullVersion: string wow64: boolean interface UALowEntropyJSON
The low-entropy values returned by NavigatorUAData.toJSON.
Properties
interface Uint8Array
Methods
toBase64(options?: { alphabet?: "base64" | "base64url"; omitPadding?: boolean; }): string Converts this Uint8Array object to a base64 string.
setFromBase64(
string: string,
options?: { alphabet?: "base64" | "base64url"; lastChunkHandling?:
"loose"
| "strict"
| "stop-before-partial"
; },
): { read: number; written: number; } Populates this Uint8Array object with data from a base64 string.
setFromHex(string: string): { read: number; written: number; } Populates this Uint8Array object with data from a hex string.
interface Uint8ArrayConstructor
Methods
fromBase64(
string: string,
options?: { alphabet?: "base64" | "base64url"; lastChunkHandling?:
"loose"
| "strict"
| "stop-before-partial"
; },
): Uint8Array<ArrayBuffer> Creates a new Uint8Array object from a base64 string.
fromHex(string: string): Uint8Array<ArrayBuffer> Creates a new Uint8Array object from a hex string.
interface VoidFunction
Call Signatures
(): void interface WebTransport
Properties
Methods
close(closeInfo?: WebTransportCloseInfo): void createBidirectionalStream(options?: WebTransportSendStreamOptions): Promise<WebTransportBidirectionalStream> createUnidirectionalStream(options?: WebTransportSendStreamOptions): Promise<WebTransportSendStream> variable WebTransport
The constructor object for WebTransport, used to open a new WebTransport session to the server at the given url.
Properties
interface WebTransportBidirectionalStream
Properties
readable: WebTransportReceiveStream writable: WebTransportSendStream variable WebTransportBidirectionalStream
The constructor object for WebTransportBidirectionalStream.
Instances are obtained from a WebTransport session rather than constructed directly.
Properties
interface WebTransportCloseInfo
interface WebTransportDatagramDuplexStream
Properties
incomingHighWaterMark: number incomingMaxAge: number | null maxDatagramSize: number outgoingHighWaterMark: number outgoingMaxAge: number | null readable: WebTransportReceiveStream writable: WebTransportSendStream variable WebTransportDatagramDuplexStream
The constructor object for WebTransportDatagramDuplexStream.
The datagram duplex stream is obtained from WebTransport.datagrams rather than constructed directly.
Properties
interface WebTransportError
Properties
source: WebTransportErrorSource streamErrorCode: number | null variable WebTransportError
The constructor object for WebTransportError, used to construct an error describing a failure of a WebTransport session or one of its streams.
Properties
interface WebTransportErrorOptions
Properties
source: WebTransportErrorSource streamErrorCode: number | null interface WebTransportHash
Properties
algorithm: string value: BufferSource interface WebTransportOptions
Properties
allowPooling: boolean requireUnreliable: boolean serverCertificateHashes: WebTransportHash[] interface WebTransportReceiveStream
Methods
getStats(): Promise<WebTransportReceiveStreamStats> variable WebTransportReceiveStream
The constructor object for WebTransportReceiveStream.
Instances are obtained from a WebTransport session rather than constructed directly.
Properties
interface WebTransportReceiveStreamStats
Properties
bytesReceived: number bytesRead: number interface WebTransportSendGroup
Methods
getStats(): Promise<WebTransportSendStreamStats> variable WebTransportSendGroup
The constructor object for WebTransportSendGroup.
Instances are obtained from a WebTransport session rather than constructed directly.
Properties
interface WebTransportSendStream
Properties
sendOrder: number sendGroup: WebTransportSendGroup Methods
variable WebTransportSendStream
The constructor object for WebTransportSendStream.
Instances are obtained from a WebTransport session rather than constructed directly.
Properties
interface WebTransportSendStreamOptions
Properties
sendGroup: WebTransportSendGroup sendOrder: number waitUntilAvailable: boolean interface WebTransportSendStreamStats
Properties
interface WebTransportWriter
Methods
atomicWrite(chunk: any): Promise<undefined> variable WebTransportWriter
The constructor object for WebTransportWriter.
Instances are obtained from a WebTransportSendStream rather than constructed directly.
Properties
interface Window
Represents the global window object in the Deno runtime environment.
While Deno doesn't have a browser window, this interface mimics browser window functionality for compatibility with web APIs. It provides access to global properties and methods such as timers, storage, and event handling.
Examples
// Accessing global objects
const localStorage = window.localStorage;
// Event handling
window.addEventListener("unhandledrejection", (event) => {
console.log("Unhandled promise rejection:", event.reason);d
});
Properties
onerror: ((
this: Window,
ev: ErrorEvent,
) => any) | null onbeforeunload: (() => any) | null onunhandledrejection: ((
this: Window,
) => any) | null onrejectionhandled: ((
this: Window,
) => any) | null close: () => void closed: boolean alert: (message?: string) => void confirm: (message?: string) => boolean prompt: (
message?: string,
defaultValue?: string,
) => string | null Deno: Deno name: string Methods
addEventListener<K extends keyof WindowEventMap>(
type: K,
listener: (
this: Window,
ev: WindowEventMap[K],
) => any,
options?: boolean | AddEventListenerOptions,
): void addEventListener(
type: string,
listener: EventListenerOrEventListenerObject,
options?: boolean | AddEventListenerOptions,
): void removeEventListener<K extends keyof WindowEventMap>(
type: K,
listener: (
this: Window,
ev: WindowEventMap[K],
) => any,
options?: boolean | EventListenerOptions,
): void removeEventListener(
type: string,
listener: EventListenerOrEventListenerObject,
options?: boolean | EventListenerOptions,
): void interface WindowEventMap
Defines the mapping between event names and their corresponding event types for the Window interface in Deno.
This interface provides type safety for event handlers by associating event names with their proper event types.
Properties
type alias AllowSharedBufferSource
type alias BufferSource
Definition
ArrayBufferView<ArrayBuffer> | ArrayBuffer type alias ImageDataArray
Definition
Uint8ClampedArray<ArrayBuffer> | Float16Array<ArrayBuffer> type alias ImageDataPixelFormat
Definition
"rgba-unorm8" | "rgba-float16" type alias PredefinedColorSpace
Definition
"srgb" | "display-p3" type alias WebTransportCongestionControl
Definition
"default"
| "low-latency"
| "throughput"
type alias WebTransportErrorSource
Definition
"session" | "stream" variable closed
Indicates whether the current window (context) is closed. In Deno, this property is primarily for API compatibility with browsers.
Type
boolean variable name
Gets or sets the name of the global scope's browsing context.
Provided for web compatibility; Deno has no browsing context, so this is an empty string by default.
Type
string variable navigator
Provides access to the Deno runtime's Navigator interface, which contains information about the environment in which the script is running.
© 2018–2025 the Deno authors
Licensed under the MIT License.
https://docs.deno.com/api/web/platform