W3cubDocs

/Deno

Deno.writeSync

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

Returns the number of bytes written. This function is one of the lowest level APIs and most users should not work with this directly, but rather use Deno.writeAllSync() instead.

It is not guaranteed that the full buffer will be written in a single call.

const encoder = new TextEncoder();
const data = encoder.encode("Hello world");
const file = Deno.openSync("/foo/bar.txt", {write: true});
const bytesWritten = Deno.writeSync(file.rid, data); // 11
Deno.close(file.rid);
function writeSync(rid: number, data: Uint8Array): number;
writeSync(rid: number, data: Uint8Array): number

Parameters

rid: number
data: Uint8Array

Return Type

number

© 2018–2021 the Deno authors
https://doc.deno.land/deno/stable/~/Deno.writeSync