Module

std/io/files.ts>readRangeSync

Deno standard library
Go to Latest
function readRangeSync
import { readRangeSync } from "https://dotland.deno.dev/std@0.119.0/io/files.ts";

Read a range of bytes synchronously from a file or other resource that is readable and seekable. The range start and end are inclusive of the bytes within that range.

import { assertEquals } from "../testing/asserts.ts";
import { readRangeSync } from "./files.ts";

// Read the first 10 bytes of a file
const file = Deno.openSync("example.txt", { read: true });
const bytes = readRangeSync(file, { start: 0, end: 9 });
assertEquals(bytes.length, 10);

Parameters

r: Deno.ReaderSync & Deno.SeekerSync
range: ByteRange

Returns

Uint8Array