blob: b33657982eba2adf422a856817879208265d988c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
import { createReadStream } from "node:fs";
import path from "node:path";
const filePath = path.join(import.meta.dirname, "hello.txt");
const readableStream = createReadStream(filePath);
readableStream.on("data", (chunk) => {
console.log(chunk.toString());
});
readableStream.on("end", () => {
console.log("Finished reading the file");
});
readableStream.on("error", (error) => {
console.error("Error reading the file:", error);
});
|