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

x/reno/deps.ts>readRangeSync

A thin, testable routing library designed to sit on top of Deno's standard HTTP module
Latest
function readRangeSync
import { readRangeSync } from "https://deno.land/x/reno@v2.0.105/deps.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 "https://deno.land/std@0.224.0/testing/asserts.ts";
import { readRangeSync } from "https://deno.land/std@0.224.0/io/read_range.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: ReaderSync & Deno.SeekerSync
range: ByteRange

Returns

Uint8Array