Skip to main content
The Deno 2 Release Candidate is here
Learn more
Module

x/deno/cli/js/lib.deno.ns.d.ts>Deno.open

A modern runtime for JavaScript and TypeScript.
Go to Latest
function Deno.open
import { Deno } from "https://deno.land/x/deno@v1.0.0/cli/js/lib.deno.ns.d.ts";
const { open } = Deno;

Open a file and resolve to an instance of Deno.File. The file does not need to previously exist if using the create or createNew open options. It is the callers responsibility to close the file when finished with it.

  const file = await Deno.open("/foo/bar.txt", { read: true, write: true });
  // Do work with file
  Deno.close(file.rid);

Requires allow-read and/or allow-write permissions depending on options.

Parameters

path: string
optional
options: OpenOptions

Returns

Promise<File>