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

x/xdg/vendor/types/deno.d.ts>Deno.readAllSync

Determine XDG Base Directory paths (OS/platform portable)
Go to Latest
function Deno.readAllSync
import { Deno } from "https://deno.land/x/xdg@v10.5.1/vendor/types/deno.d.ts";
const { readAllSync } = Deno;

Synchronously reads Reader r until EOF (null) and returns the content as Uint8Array.

// Example from stdin
const stdinContent = Deno.readAllSync(Deno.stdin);

// Example from file
const file = Deno.openSync("my_file.txt", {read: true});
const myFileContent = Deno.readAllSync(file);
Deno.close(file.rid);

// Example from buffer
const myData = new Uint8Array(100);
// ... fill myData array with data
const reader = new Deno.Buffer(myData.buffer as ArrayBuffer);
const bufferContent = Deno.readAllSync(reader);

Returns

Uint8Array