Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/ayonli_jsext/lib.deno.d.ts>Deno.writeSync

A JavaScript extension package for building strong and modern applications.
Latest
function Deno.writeSync
Deprecated
Deprecated

This will be removed in Deno 2.0. See the Deno 1.x to 2.x Migration Guide for migration instructions.

import { Deno } from "https://deno.land/x/ayonli_jsext@v0.9.72/lib.deno.d.ts";
const { writeSync } = Deno;

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 WritableStream, ReadableStream.from and ReadableStream.pipeTo.

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");
using file = Deno.openSync("/foo/bar.txt", { write: true });
const bytesWritten = Deno.writeSync(file.rid, data); // 11

Parameters

rid: number
data: Uint8Array

Returns

number