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

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

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

Write to the resource ID (rid) the contents of the array buffer (data).

Resolves to the number of bytes written.

 const encoder = new TextEncoder();
 const data = encoder.encode("Hello world");
 const file = await Deno.open("/foo/bar.txt");
 const bytesWritten = await Deno.write(file.rid, data); // 11
 Deno.close(file.rid);

Parameters

rid: number
data: Uint8Array

Returns

Promise<number>