function read
read(path: string | URL): Enumerable<Uint8Array>

Open a file for reading as an AsyncIterable of byte chunks.

Returns an Enumerable that can be transformed, piped to processes, or converted to lines. The file is automatically closed when iteration completes.

Examples

Read a file and process it

import { read } from "jsr:@j50n/proc";

const bytes = await read("data.txt").collect();
const text = new TextDecoder().decode(concat(bytes));

Parameters

path: string | URL

The path of the file.

Return Type

An Enumerable of byte chunks.

Usage

import { read } from ".";