Skip to main content
Module

x/silicon/deps.ts>io.readRange

Deno module to generate images from source code using Aloxaf/silicon.
Go to Latest
function io.readRange
import { io } from "https://deno.land/x/silicon@v0.0.5/deps.ts";
const { readRange } = io;

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 "https://deno.land/std@0.224.0/testing/asserts.ts";
import { readRange } from "https://deno.land/std@0.224.0/io/read_range.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>