Module

x/proc/legacy/deps.ts>readRangeSync

A better way to work with processes in Deno.
Very Popular
Latest
function readRangeSync
Deprecated
Deprecated

(will be removed after 1.0.0) Use the [Web Streams API]https://developer.mozilla.org/en-US/docs/Web/API/Streams_API instead.

import { readRangeSync } from "https://dotland.deno.dev/x/proc@0.21.9/legacy/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@$STD_VERSION/assert/assert_equals.ts";
import { readRangeSync } from "https://deno.land/std@$STD_VERSION/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