Skip to main content
Module

std/io/files.ts>readRange

Deno standard library
Go to Latest
function readRange
import { readRange } from "https://deno.land/std@0.114.0/io/files.ts";

Read a range of bytes 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 { readRange } from "./files.ts";

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

Returns

Promise<Uint8Array>