Skip to main content
Module

x/deno/js/deno.ts

A modern runtime for JavaScript and TypeScript.
Go to Latest
import * as deno from "https://deno.land/x/deno@v0.17.0/js/deno.ts";

Classes

A Buffer is a variable-sized buffer of bytes with read() and write() methods. Based on https://golang.org/pkg/bytes/#Buffer

A Deno specific error. The kind property is set to a specific error code which can be used to in application logic.

The Deno abstraction for reading and writing files.

Variables

A symbol which can be used as a key for a custom method which will be called when Deno.inspect() is called, or when the object is logged to the console.

Reflects the NO_COLOR environment variable: https://no-color.org/

The current process id of the runtime.

Signals numbers. This is platform dependent.

An instance of File for stderr.

An instance of File for stdin.

An instance of File for stdout.

Functions

Given a current location in a module, lookup the source location and return it.

chdir() Change the current working directory to path. throws NotFound exception if directory not available

Changes the permission of a specific file/directory of specified path.

Changes the permission of a specific file/directory of specified path synchronously.

Change owner of a regular file or directory asynchronously. Unix only at the moment.

Change owner of a regular file or directory synchronously. Unix only at the moment.

Close the file ID.

RESERVED

Copies from src to dst until either EOF is reached on src or an error occurs. It returns the number of bytes copied and the first error encountered while copying, if any.

Copies the contents of a file to another by name.

Copies the contents of a file to another by name synchronously. Creates a new file if target does not exists, and if target exists, overwrites original content of the target file.

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. throws NotFound exception if directory not available

Dial connects to the address on the named network.

Mixes in a DOM iterable methods into a base class, assumes that there is a private data iterable that is part of the base class, located at [dataSymbol]. TODO Don't expose DomIterableMixin from "deno" namespace.

Returns a snapshot of the environment variables at invocation. Mutating a property in the object will set that variable in the environment for the process. The environment object will only accept strings as values.

Returns the path to the current deno executable. Requires the --allow-env flag.

Exit the Deno process with optional exit code.

Returns the current user's home directory. Requires the --allow-env flag.

inspect() converts input into string that has the same format as printed by console.log(...);

Check if running in terminal.

Send a signal to process under given PID. Unix only at this moment. If pid is negative, the signal will be sent to the process group identified by -pid. Requires the --allow-run flag.

Creates newname as a hard link to oldname.

Synchronously creates newname as a hard link to oldname.

Listen announces on the local network address.

Queries the file system for information on the path provided. If the given path is a symlink information about the symlink will be returned.

Queries the file system for information on the path provided synchronously. If the given path is a symlink information about the symlink will be returned.

makeTempDir creates a new temporary directory in the directory dir, its name beginning with prefix and ending with suffix. It returns the full path to the newly created directory. If dir is unspecified, tempDir uses the default directory for temporary files. Multiple programs calling tempDir simultaneously will not choose the same directory. It is the caller's responsibility to remove the directory when no longer needed.

makeTempDirSync is the synchronous version of makeTempDir.

Receive metrics from the privileged side of Deno.

Creates a new directory with the specified path. If recursive is set to true, nested directories will be created (also known as "mkdir -p"). mode sets permission bits (before umask) on UNIX and does nothing on Windows.

Creates a new directory with the specified path synchronously. If recursive is set to true, nested directories will be created (also known as "mkdir -p"). mode sets permission bits (before umask) on UNIX and does nothing on Windows.

Open a file and return an instance of the File object.

Open a file and return an instance of the File object synchronously.

Inspect granted permissions for the current program.

Read from a file ID into an array buffer.

Read r until EOF and return the content as Uint8Array.

Read synchronously r until EOF and return the content as Uint8Array.

Reads the directory given by path and returns a list of file info.

Reads the directory given by path and returns a list of file info synchronously.

Read the entire contents of a file.

Read the entire contents of a file synchronously.

Returns the destination of the named symbolic link.

Returns the destination of the named symbolic link synchronously.

Read synchronously from a file ID into an array buffer.

Removes the named file or directory. Would throw error if permission denied, not found, or directory not empty if recursive set to false. recursive is set to false by default.

Removes the named file or directory synchronously. Would throw error if permission denied, not found, or directory not empty if recursive set to false. recursive is set to false by default.

Renames (moves) oldpath to newpath. If newpath already exists and is not a directory, rename() replaces it. OS-specific restrictions may apply when oldpath and newpath are in different directories.

Synchronously renames (moves) oldpath to newpath. If newpath already exists and is not a directory, renameSync() replaces it. OS-specific restrictions may apply when oldpath and newpath are in different directories.

Returns a map of open file like resource ids along with their string representation.

Revoke a permission. When the permission was already revoked nothing changes

Spawns new subprocess.

Seek a file ID to the given offset under mode given by whence.

Seek a file ID synchronously to the given offset under mode given by whence.

Sets the prepareStackTrace method on the Error constructor which will op into Rust to remap source code for caught errors where the .stack is being accessed.

Queries the file system for information on the path provided. stat Will always follow symlinks.

Queries the file system for information on the path provided synchronously. statSync Will always follow symlinks.

TODO Do not expose this from "deno" namespace.

Creates newname as a symbolic link to oldname. The type argument can be set to dir or file and is only available on Windows (ignored on other platforms).

Synchronously creates newname as a symbolic link to oldname. The type argument can be set to dir or file and is only available on Windows (ignored on other platforms).

Turns r into async iterator.

Truncates or extends the specified file, updating the size of this file to become size.

Truncates or extends the specified file synchronously, updating the size of this file to become size.

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

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

Write to the file ID the contents of the array buffer.

Write all the content of arr to w.

Write synchronously all the content of arr to w.

Write a new file, with given filename and data.

Write a new file, with given filename and data synchronously.

Write synchronously to the file ID the contents of the array buffer.

Interfaces

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

A Listener is a generic network listener for stream-oriented protocols.

Permissions as granted by the caller

Options for writing to a file. perm would change the file's permission if set. create decides if the file should be created if not exists (default: true) append decides if the file should be appended (default: false)